mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-20 13:49:52 -07:00
Update modalkit dependencies (#204)
This commit is contained in:
parent
1cb280df8b
commit
1325295d2b
19 changed files with 199 additions and 235 deletions
39
src/base.rs
39
src/base.rs
|
@ -12,6 +12,12 @@ use std::sync::Arc;
|
|||
use std::time::{Duration, Instant};
|
||||
|
||||
use emojis::Emoji;
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{Alignment, Rect},
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, Widget},
|
||||
};
|
||||
use ratatui_image::picker::{Picker, ProtocolType};
|
||||
use serde::{
|
||||
de::Error as SerdeError,
|
||||
|
@ -61,7 +67,6 @@ use modalkit::{
|
|||
ApplicationStore,
|
||||
ApplicationWindowId,
|
||||
},
|
||||
base::{CommandType, WordStyle},
|
||||
completion::{complete_path, CompletionMap},
|
||||
context::EditContext,
|
||||
cursor::Cursor,
|
||||
|
@ -71,16 +76,10 @@ use modalkit::{
|
|||
env::vim::{
|
||||
command::{CommandContext, CommandDescription, VimCommand, VimCommandMachine},
|
||||
keybindings::VimMachine,
|
||||
VimContext,
|
||||
},
|
||||
input::bindings::SequenceStatus,
|
||||
input::key::TerminalKey,
|
||||
tui::{
|
||||
buffer::Buffer,
|
||||
layout::{Alignment, Rect},
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, Widget},
|
||||
},
|
||||
key::TerminalKey,
|
||||
keybindings::SequenceStatus,
|
||||
prelude::{CommandType, WordStyle},
|
||||
};
|
||||
|
||||
use crate::config::ImagePreviewProtocolValues;
|
||||
|
@ -365,7 +364,7 @@ pub enum RoomAction {
|
|||
Leave(bool),
|
||||
|
||||
/// Open the members window.
|
||||
Members(Box<CommandContext<ProgramContext>>),
|
||||
Members(Box<CommandContext>),
|
||||
|
||||
/// Set a room property.
|
||||
Set(RoomField, String),
|
||||
|
@ -460,7 +459,7 @@ impl From<SendAction> for IambAction {
|
|||
}
|
||||
|
||||
impl ApplicationAction for IambAction {
|
||||
fn is_edit_sequence<C: EditContext>(&self, _: &C) -> SequenceStatus {
|
||||
fn is_edit_sequence(&self, _: &EditContext) -> SequenceStatus {
|
||||
match self {
|
||||
IambAction::Homeserver(..) => SequenceStatus::Break,
|
||||
IambAction::Message(..) => SequenceStatus::Break,
|
||||
|
@ -473,7 +472,7 @@ impl ApplicationAction for IambAction {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_last_action<C: EditContext>(&self, _: &C) -> SequenceStatus {
|
||||
fn is_last_action(&self, _: &EditContext) -> SequenceStatus {
|
||||
match self {
|
||||
IambAction::Homeserver(..) => SequenceStatus::Atom,
|
||||
IambAction::Message(..) => SequenceStatus::Atom,
|
||||
|
@ -486,7 +485,7 @@ impl ApplicationAction for IambAction {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_last_selection<C: EditContext>(&self, _: &C) -> SequenceStatus {
|
||||
fn is_last_selection(&self, _: &EditContext) -> SequenceStatus {
|
||||
match self {
|
||||
IambAction::Homeserver(..) => SequenceStatus::Ignore,
|
||||
IambAction::Message(..) => SequenceStatus::Ignore,
|
||||
|
@ -499,7 +498,7 @@ impl ApplicationAction for IambAction {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_switchable<C: EditContext>(&self, _: &C) -> bool {
|
||||
fn is_switchable(&self, _: &EditContext) -> bool {
|
||||
match self {
|
||||
IambAction::Homeserver(..) => false,
|
||||
IambAction::Message(..) => false,
|
||||
|
@ -528,13 +527,13 @@ impl From<IambAction> for ProgramAction {
|
|||
/// Alias for program actions.
|
||||
pub type ProgramAction = Action<IambInfo>;
|
||||
/// Alias for program context.
|
||||
pub type ProgramContext = VimContext<IambInfo>;
|
||||
pub type ProgramContext = EditContext;
|
||||
/// Alias for program keybindings.
|
||||
pub type Keybindings = VimMachine<TerminalKey, IambInfo>;
|
||||
/// Alias for a program command.
|
||||
pub type ProgramCommand = VimCommand<ProgramContext, IambInfo>;
|
||||
pub type ProgramCommand = VimCommand<IambInfo>;
|
||||
/// Alias for mapped program commands.
|
||||
pub type ProgramCommands = VimCommandMachine<ProgramContext, IambInfo>;
|
||||
pub type ProgramCommands = VimCommandMachine<IambInfo>;
|
||||
/// Alias for program store.
|
||||
pub type ProgramStore = Store<IambInfo>;
|
||||
/// Alias for shared program store.
|
||||
|
@ -1612,7 +1611,7 @@ fn complete_cmd(
|
|||
/// Tab completion for the command bar.
|
||||
fn complete_cmdbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -> Vec<String> {
|
||||
let eo = text.cursor_to_offset(cursor);
|
||||
let slice = text.slice(0.into(), eo, false);
|
||||
let slice = text.slice(..eo);
|
||||
let cow = Cow::from(&slice);
|
||||
|
||||
complete_cmd(cow.as_ref(), text, cursor, store)
|
||||
|
@ -1623,7 +1622,7 @@ pub mod tests {
|
|||
use super::*;
|
||||
use crate::config::user_style_from_color;
|
||||
use crate::tests::*;
|
||||
use modalkit::tui::style::Color;
|
||||
use ratatui::style::Color;
|
||||
|
||||
#[test]
|
||||
fn test_typing_spans() {
|
||||
|
|
|
@ -7,10 +7,9 @@ use std::convert::TryFrom;
|
|||
use matrix_sdk::ruma::{events::tag::TagName, OwnedUserId};
|
||||
|
||||
use modalkit::{
|
||||
editing::base::OpenTarget,
|
||||
commands::{CommandError, CommandResult, CommandStep},
|
||||
env::vim::command::{CommandContext, CommandDescription, OptionType},
|
||||
input::commands::{CommandError, CommandResult, CommandStep},
|
||||
input::InputContext,
|
||||
prelude::OpenTarget,
|
||||
};
|
||||
|
||||
use crate::base::{
|
||||
|
@ -23,14 +22,13 @@ use crate::base::{
|
|||
MessageAction,
|
||||
ProgramCommand,
|
||||
ProgramCommands,
|
||||
ProgramContext,
|
||||
RoomAction,
|
||||
RoomField,
|
||||
SendAction,
|
||||
VerifyAction,
|
||||
};
|
||||
|
||||
type ProgContext = CommandContext<ProgramContext>;
|
||||
type ProgContext = CommandContext;
|
||||
type ProgResult = CommandResult<ProgramCommand>;
|
||||
|
||||
/// Convert strings the user types into a tag name.
|
||||
|
@ -99,7 +97,7 @@ fn iamb_invite(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
};
|
||||
|
||||
let iact = IambAction::from(ract);
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -110,7 +108,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
match args.len() {
|
||||
0 => {
|
||||
let open = ctx.switch(OpenTarget::Application(IambId::VerifyList));
|
||||
let step = CommandStep::Continue(open, ctx.context.take());
|
||||
let step = CommandStep::Continue(open, ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
},
|
||||
|
@ -125,7 +123,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
"mismatch" => VerifyAction::Mismatch,
|
||||
"request" => {
|
||||
let iact = IambAction::VerifyRequest(args.remove(1));
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
},
|
||||
|
@ -133,7 +131,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
};
|
||||
|
||||
let vact = IambAction::Verify(act, args.remove(1));
|
||||
let step = CommandStep::Continue(vact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(vact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
},
|
||||
|
@ -149,7 +147,7 @@ fn iamb_dms(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let open = ctx.switch(OpenTarget::Application(IambId::DirectList));
|
||||
let step = CommandStep::Continue(open, ctx.context.take());
|
||||
let step = CommandStep::Continue(open, ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -160,7 +158,7 @@ fn iamb_members(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let open = IambAction::Room(RoomAction::Members(ctx.clone().into()));
|
||||
let step = CommandStep::Continue(open.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(open.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -171,7 +169,7 @@ fn iamb_leave(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let leave = IambAction::Room(RoomAction::Leave(desc.bang));
|
||||
let step = CommandStep::Continue(leave.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(leave.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -182,7 +180,7 @@ fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let mact = IambAction::from(MessageAction::Cancel(desc.bang));
|
||||
let step = CommandStep::Continue(mact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(mact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -193,7 +191,7 @@ fn iamb_edit(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let mact = IambAction::from(MessageAction::Edit);
|
||||
let step = CommandStep::Continue(mact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(mact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -209,7 +207,7 @@ fn iamb_react(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
|
||||
if let Some(emoji) = emojis::get(k).or_else(|| emojis::get_by_shortcode(k)) {
|
||||
let mact = IambAction::from(MessageAction::React(emoji.to_string()));
|
||||
let step = CommandStep::Continue(mact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(mact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
} else {
|
||||
|
@ -240,7 +238,7 @@ fn iamb_unreact(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
IambAction::from(MessageAction::Unreact(None))
|
||||
};
|
||||
|
||||
let step = CommandStep::Continue(mact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(mact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -254,7 +252,7 @@ fn iamb_redact(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
|
||||
let reason = args.into_iter().next();
|
||||
let ract = IambAction::from(MessageAction::Redact(reason, desc.bang));
|
||||
let step = CommandStep::Continue(ract.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(ract.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -265,7 +263,7 @@ fn iamb_reply(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let ract = IambAction::from(MessageAction::Reply);
|
||||
let step = CommandStep::Continue(ract.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(ract.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -276,7 +274,7 @@ fn iamb_editor(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let sact = IambAction::from(SendAction::SubmitFromEditor);
|
||||
let step = CommandStep::Continue(sact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(sact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -287,7 +285,7 @@ fn iamb_rooms(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let open = ctx.switch(OpenTarget::Application(IambId::RoomList));
|
||||
let step = CommandStep::Continue(open, ctx.context.take());
|
||||
let step = CommandStep::Continue(open, ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -298,7 +296,7 @@ fn iamb_chats(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let open = ctx.switch(OpenTarget::Application(IambId::ChatList));
|
||||
let step = CommandStep::Continue(open, ctx.context.take());
|
||||
let step = CommandStep::Continue(open, ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -309,7 +307,7 @@ fn iamb_spaces(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let open = ctx.switch(OpenTarget::Application(IambId::SpaceList));
|
||||
let step = CommandStep::Continue(open, ctx.context.take());
|
||||
let step = CommandStep::Continue(open, ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -320,7 +318,7 @@ fn iamb_welcome(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let open = ctx.switch(OpenTarget::Application(IambId::Welcome));
|
||||
let step = CommandStep::Continue(open, ctx.context.take());
|
||||
let step = CommandStep::Continue(open, ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -333,7 +331,7 @@ fn iamb_join(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let open = ctx.switch(args.remove(0));
|
||||
let step = CommandStep::Continue(open, ctx.context.take());
|
||||
let step = CommandStep::Continue(open, ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -380,7 +378,7 @@ fn iamb_create(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
|
||||
let hact = HomeserverAction::CreateRoom(alias, ct, flags);
|
||||
let iact = IambAction::from(hact);
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -427,7 +425,7 @@ fn iamb_room(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
_ => return Result::Err(CommandError::InvalidArgument),
|
||||
};
|
||||
|
||||
let step = CommandStep::Continue(act.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(act.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -441,7 +439,7 @@ fn iamb_upload(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
|
||||
let sact = SendAction::Upload(args.remove(0));
|
||||
let iact = IambAction::from(sact);
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -459,7 +457,7 @@ fn iamb_download(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult
|
|||
};
|
||||
let mact = MessageAction::Download(args.pop(), flags);
|
||||
let iact = IambAction::from(mact);
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -477,7 +475,7 @@ fn iamb_open(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
};
|
||||
let mact = MessageAction::Download(args.pop(), flags);
|
||||
let iact = IambAction::from(mact);
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -490,7 +488,7 @@ fn iamb_logout(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
|
|||
}
|
||||
|
||||
let iact = IambAction::from(HomeserverAction::Logout(args[0].clone(), desc.bang));
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.take());
|
||||
let step = CommandStep::Continue(iact.into(), ctx.context.clone());
|
||||
|
||||
return Ok(step);
|
||||
}
|
||||
|
@ -607,11 +605,12 @@ mod tests {
|
|||
use super::*;
|
||||
use matrix_sdk::ruma::user_id;
|
||||
use modalkit::editing::action::WindowAction;
|
||||
use modalkit::editing::context::EditContext;
|
||||
|
||||
#[test]
|
||||
fn test_cmd_verify() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd(":verify", ctx.clone()).unwrap();
|
||||
let act = WindowAction::Switch(OpenTarget::Application(IambId::VerifyList));
|
||||
|
@ -658,7 +657,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_join() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd("join #foobar:example.com", ctx.clone()).unwrap();
|
||||
let act = WindowAction::Switch(OpenTarget::Name("#foobar:example.com".into()));
|
||||
|
@ -678,7 +677,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_room_invalid() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd("room", ctx.clone());
|
||||
assert_eq!(res, Err(CommandError::InvalidArgument));
|
||||
|
@ -693,7 +692,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_room_topic_set() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds
|
||||
.input_cmd("room topic set \"Lots of fun discussion!\"", ctx.clone())
|
||||
|
@ -724,7 +723,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_room_name_invalid() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd("room name", ctx.clone());
|
||||
assert_eq!(res, Err(CommandError::InvalidArgument));
|
||||
|
@ -736,7 +735,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_room_name_set() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd("room name set Development", ctx.clone()).unwrap();
|
||||
let act = RoomAction::Set(RoomField::Name, "Development".into());
|
||||
|
@ -755,7 +754,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_room_name_unset() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd("room name unset", ctx.clone()).unwrap();
|
||||
let act = RoomAction::Unset(RoomField::Name);
|
||||
|
@ -768,7 +767,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_room_tag_set() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd("room tag set favourite", ctx.clone()).unwrap();
|
||||
let act = RoomAction::Set(RoomField::Tag(TagName::Favorite), "".into());
|
||||
|
@ -837,7 +836,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_room_tag_unset() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd("room tag unset favourite", ctx.clone()).unwrap();
|
||||
let act = RoomAction::Unset(RoomField::Tag(TagName::Favorite));
|
||||
|
@ -902,7 +901,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_invite() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd("invite accept", ctx.clone()).unwrap();
|
||||
let act = IambAction::Room(RoomAction::InviteAccept);
|
||||
|
@ -939,7 +938,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_cmd_redact() {
|
||||
let mut cmds = setup_commands();
|
||||
let ctx = ProgramContext::default();
|
||||
let ctx = EditContext::default();
|
||||
|
||||
let res = cmds.input_cmd("redact", ctx.clone()).unwrap();
|
||||
let act = IambAction::Message(MessageAction::Redact(None, false));
|
||||
|
|
|
@ -11,16 +11,13 @@ use std::process;
|
|||
|
||||
use clap::Parser;
|
||||
use matrix_sdk::ruma::{OwnedRoomAliasId, OwnedRoomId, OwnedUserId, UserId};
|
||||
use ratatui::style::{Color, Modifier as StyleModifier, Style};
|
||||
use ratatui::text::Span;
|
||||
use ratatui_image::picker::ProtocolType;
|
||||
use serde::{de::Error as SerdeError, de::Visitor, Deserialize, Deserializer};
|
||||
use tracing::Level;
|
||||
use url::Url;
|
||||
|
||||
use modalkit::tui::{
|
||||
style::{Color, Modifier as StyleModifier, Style},
|
||||
text::Span,
|
||||
};
|
||||
|
||||
use super::base::{IambId, RoomInfo, SortColumn, SortFieldRoom, SortFieldUser, SortOrder};
|
||||
|
||||
macro_rules! usage {
|
||||
|
|
|
@ -6,8 +6,8 @@ use modalkit::{
|
|||
editing::action::WindowAction,
|
||||
env::vim::keybindings::{InputStep, VimBindings},
|
||||
env::vim::VimMode,
|
||||
input::bindings::{EdgeEvent, EdgeRepeat, InputBindings},
|
||||
input::key::TerminalKey,
|
||||
key::TerminalKey,
|
||||
keybindings::{EdgeEvent, EdgeRepeat, InputBindings},
|
||||
};
|
||||
|
||||
use crate::base::{IambAction, IambInfo, Keybindings, MATRIX_ID_WORD};
|
||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -54,7 +54,7 @@ use modalkit::crossterm::{
|
|||
terminal::{EnterAlternateScreen, LeaveAlternateScreen, SetTitle},
|
||||
};
|
||||
|
||||
use modalkit::tui::{
|
||||
use ratatui::{
|
||||
backend::CrosstermBackend,
|
||||
layout::Rect,
|
||||
style::{Color, Style},
|
||||
|
@ -116,20 +116,26 @@ use modalkit::{
|
|||
WindowAction,
|
||||
WindowContainer,
|
||||
},
|
||||
base::{CloseFlags, MoveDir1D, OpenTarget, RepeatType, TabTarget},
|
||||
context::Resolve,
|
||||
key::KeyManager,
|
||||
store::Store,
|
||||
},
|
||||
input::{bindings::BindingMachine, dialog::Pager, dialog::PromptYesNo, key::TerminalKey},
|
||||
widgets::{
|
||||
cmdbar::CommandBarState,
|
||||
screen::{FocusList, Screen, ScreenState, TabLayoutDescription},
|
||||
windows::WindowLayoutDescription,
|
||||
TerminalCursor,
|
||||
TerminalExtOps,
|
||||
Window,
|
||||
key::TerminalKey,
|
||||
keybindings::{
|
||||
dialog::{Pager, PromptYesNo},
|
||||
BindingMachine,
|
||||
},
|
||||
prelude::*,
|
||||
ui::FocusList,
|
||||
};
|
||||
|
||||
use modalkit_ratatui::{
|
||||
cmdbar::CommandBarState,
|
||||
screen::{Screen, ScreenState, TabLayoutDescription},
|
||||
windows::WindowLayoutDescription,
|
||||
TerminalCursor,
|
||||
TerminalExtOps,
|
||||
Window,
|
||||
};
|
||||
|
||||
fn config_tab_to_desc(
|
||||
|
@ -229,7 +235,7 @@ struct Application {
|
|||
worker: Requester,
|
||||
|
||||
/// Mapped keybindings.
|
||||
bindings: KeyManager<TerminalKey, ProgramAction, RepeatType, ProgramContext>,
|
||||
bindings: KeyManager<TerminalKey, ProgramAction, RepeatType>,
|
||||
|
||||
/// Pending actions to run.
|
||||
actstack: VecDeque<(ProgramAction, ProgramContext)>,
|
||||
|
|
|
@ -26,7 +26,7 @@ use html5ever::{
|
|||
tendril::{StrTendril, TendrilSink},
|
||||
};
|
||||
|
||||
use modalkit::tui::{
|
||||
use ratatui::{
|
||||
layout::Alignment,
|
||||
style::{Color, Modifier as StyleModifier, Style},
|
||||
symbols::line,
|
||||
|
|
|
@ -44,13 +44,14 @@ use matrix_sdk::ruma::{
|
|||
UInt,
|
||||
};
|
||||
|
||||
use modalkit::tui::{
|
||||
use ratatui::{
|
||||
style::{Modifier as StyleModifier, Style},
|
||||
symbols::line::THICK_VERTICAL,
|
||||
text::{Line, Span, Text},
|
||||
};
|
||||
|
||||
use modalkit::editing::{base::ViewportContext, cursor::Cursor};
|
||||
use modalkit::editing::cursor::Cursor;
|
||||
use modalkit::prelude::*;
|
||||
use ratatui_image::protocol::Protocol;
|
||||
|
||||
use crate::config::ImagePreviewSize;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
//! contents).
|
||||
use std::borrow::Cow;
|
||||
|
||||
use modalkit::tui::layout::Alignment;
|
||||
use modalkit::tui::style::Style;
|
||||
use modalkit::tui::text::{Line, Span, Text};
|
||||
use ratatui::layout::Alignment;
|
||||
use ratatui::style::Style;
|
||||
use ratatui::text::{Line, Span, Text};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use matrix_sdk::{
|
|||
},
|
||||
Media,
|
||||
};
|
||||
use modalkit::tui::layout::Rect;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui_image::Resize;
|
||||
|
||||
use crate::{
|
||||
|
|
|
@ -15,7 +15,7 @@ use matrix_sdk::ruma::{
|
|||
};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use modalkit::tui::style::{Color, Style};
|
||||
use ratatui::style::{Color, Style};
|
||||
use tokio::sync::mpsc::unbounded_channel;
|
||||
use tracing::Level;
|
||||
use url::Url;
|
||||
|
|
|
@ -4,8 +4,8 @@ use std::borrow::Cow;
|
|||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use modalkit::tui::style::Style;
|
||||
use modalkit::tui::text::{Line, Span, Text};
|
||||
use ratatui::style::Style;
|
||||
use ratatui::text::{Line, Span, Text};
|
||||
|
||||
pub fn split_cow(cow: Cow<'_, str>, idx: usize) -> (Cow<'_, str>, Cow<'_, str>) {
|
||||
match cow {
|
||||
|
|
|
@ -24,7 +24,7 @@ use matrix_sdk::{
|
|||
},
|
||||
};
|
||||
|
||||
use modalkit::tui::{
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{Alignment, Rect},
|
||||
style::{Modifier as StyleModifier, Style},
|
||||
|
@ -48,25 +48,17 @@ use modalkit::{
|
|||
UIError,
|
||||
WindowAction,
|
||||
},
|
||||
base::{
|
||||
CloseFlags,
|
||||
MoveDir1D,
|
||||
OpenTarget,
|
||||
PositionList,
|
||||
ScrollStyle,
|
||||
ViewportContext,
|
||||
WordStyle,
|
||||
WriteFlags,
|
||||
},
|
||||
completion::CompletionList,
|
||||
},
|
||||
widgets::{
|
||||
list::{List, ListCursor, ListItem, ListState},
|
||||
TermOffset,
|
||||
TerminalCursor,
|
||||
Window,
|
||||
WindowOps,
|
||||
},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
use modalkit_ratatui::{
|
||||
list::{List, ListCursor, ListItem, ListState},
|
||||
TermOffset,
|
||||
TerminalCursor,
|
||||
Window,
|
||||
WindowOps,
|
||||
};
|
||||
|
||||
use crate::base::{
|
||||
|
@ -281,7 +273,6 @@ fn room_prompt(
|
|||
|
||||
Err(err)
|
||||
},
|
||||
_ => Err(EditError::Unimplemented("unknown prompt action".to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1332,7 +1323,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for VerifyItem {
|
|||
|
||||
Err(err)
|
||||
},
|
||||
_ => Err(EditError::Unimplemented("unknown prompt action".to_string())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1428,7 +1418,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for MemberItem {
|
|||
|
||||
Err(err)
|
||||
},
|
||||
_ => Err(EditError::Unimplemented("unknown prompt action".to_string())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,17 +31,20 @@ use matrix_sdk::{
|
|||
},
|
||||
};
|
||||
|
||||
use modalkit::{
|
||||
input::dialog::{MultiChoice, MultiChoiceItem, PromptYesNo},
|
||||
tui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, StatefulWidget, Widget},
|
||||
},
|
||||
widgets::textbox::{TextBox, TextBoxState},
|
||||
widgets::TerminalCursor,
|
||||
widgets::{PromptActions, WindowOps},
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, StatefulWidget, Widget},
|
||||
};
|
||||
|
||||
use modalkit::keybindings::dialog::{MultiChoice, MultiChoiceItem, PromptYesNo};
|
||||
|
||||
use modalkit_ratatui::{
|
||||
textbox::{TextBox, TextBoxState},
|
||||
PromptActions,
|
||||
TerminalCursor,
|
||||
WindowOps,
|
||||
};
|
||||
|
||||
use modalkit::editing::{
|
||||
|
@ -59,12 +62,12 @@ use modalkit::editing::{
|
|||
Scrollable,
|
||||
UIError,
|
||||
},
|
||||
base::{CloseFlags, Count, MoveDir1D, PositionList, ScrollStyle, WordStyle, WriteFlags},
|
||||
completion::CompletionList,
|
||||
context::Resolve,
|
||||
history::{self, HistoryList},
|
||||
rope::EditRope,
|
||||
};
|
||||
use modalkit::prelude::*;
|
||||
|
||||
use crate::base::{
|
||||
DownloadFlags,
|
||||
|
@ -811,7 +814,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ChatState {
|
|||
PromptAction::Recall(dir, count, prefixed) => {
|
||||
self.recall(dir, count, *prefixed, ctx, store)
|
||||
},
|
||||
_ => Err(EditError::Unimplemented("unknown prompt action".to_string())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use matrix_sdk::{
|
|||
DisplayName,
|
||||
};
|
||||
|
||||
use modalkit::tui::{
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{Alignment, Rect},
|
||||
style::{Modifier as StyleModifier, Style},
|
||||
|
@ -19,6 +19,7 @@ use modalkit::tui::{
|
|||
widgets::{Paragraph, StatefulWidget, Widget},
|
||||
};
|
||||
|
||||
use modalkit::prelude::*;
|
||||
use modalkit::{
|
||||
editing::action::{
|
||||
Action,
|
||||
|
@ -32,22 +33,10 @@ use modalkit::{
|
|||
Scrollable,
|
||||
UIError,
|
||||
},
|
||||
editing::base::{
|
||||
Axis,
|
||||
CloseFlags,
|
||||
Count,
|
||||
MoveDir1D,
|
||||
OpenTarget,
|
||||
PositionList,
|
||||
ScrollStyle,
|
||||
WordStyle,
|
||||
WriteFlags,
|
||||
},
|
||||
editing::completion::CompletionList,
|
||||
input::dialog::PromptYesNo,
|
||||
input::InputContext,
|
||||
widgets::{TermOffset, TerminalCursor, WindowOps},
|
||||
keybindings::dialog::PromptYesNo,
|
||||
};
|
||||
use modalkit_ratatui::{TermOffset, TerminalCursor, WindowOps};
|
||||
|
||||
use crate::base::{
|
||||
IambAction,
|
||||
|
@ -253,7 +242,7 @@ impl RoomState {
|
|||
width.into(),
|
||||
);
|
||||
|
||||
Ok(vec![(act, cmd.context.take())])
|
||||
Ok(vec![(act, cmd.context.clone())])
|
||||
},
|
||||
RoomAction::Set(field, value) => {
|
||||
let room = store
|
||||
|
|
|
@ -5,14 +5,14 @@ use regex::Regex;
|
|||
|
||||
use matrix_sdk::ruma::OwnedRoomId;
|
||||
|
||||
use modalkit::tui::{
|
||||
use modalkit_ratatui::{ScrollActions, TerminalCursor, WindowOps};
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{Alignment, Rect},
|
||||
style::{Modifier as StyleModifier, Style},
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, StatefulWidget, Widget},
|
||||
};
|
||||
use modalkit::widgets::{ScrollActions, TerminalCursor, WindowOps};
|
||||
|
||||
use modalkit::editing::{
|
||||
action::{
|
||||
|
@ -36,40 +36,14 @@ use modalkit::editing::{
|
|||
UIError,
|
||||
UIResult,
|
||||
},
|
||||
base::{
|
||||
Axis,
|
||||
CloseFlags,
|
||||
CompletionDisplay,
|
||||
CompletionSelection,
|
||||
CompletionType,
|
||||
Count,
|
||||
EditRange,
|
||||
EditTarget,
|
||||
Mark,
|
||||
MoveDir1D,
|
||||
MoveDir2D,
|
||||
MoveDirMod,
|
||||
MovePosition,
|
||||
MoveTerminus,
|
||||
MoveType,
|
||||
PositionList,
|
||||
RangeType,
|
||||
Register,
|
||||
ScrollSize,
|
||||
ScrollStyle,
|
||||
SearchType,
|
||||
TargetShape,
|
||||
ViewportContext,
|
||||
WordStyle,
|
||||
WriteFlags,
|
||||
},
|
||||
completion::CompletionList,
|
||||
context::{EditContext, Resolve},
|
||||
context::Resolve,
|
||||
cursor::{CursorGroup, CursorState},
|
||||
history::HistoryList,
|
||||
rope::EditRope,
|
||||
store::{RegisterCell, RegisterPutFlags},
|
||||
};
|
||||
use modalkit::prelude::*;
|
||||
|
||||
use crate::{
|
||||
base::{
|
||||
|
@ -620,15 +594,9 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
|||
let dir = ctx.get_search_regex_dir();
|
||||
let dir = flip.resolve(&dir);
|
||||
|
||||
let needle = match ctx.get_search_regex() {
|
||||
Some(re) => re,
|
||||
None => {
|
||||
let lsearch = store.registers.get(&Register::LastSearch)?;
|
||||
let lsearch = lsearch.value.to_string();
|
||||
|
||||
Regex::new(lsearch.as_ref())?
|
||||
},
|
||||
};
|
||||
let lsearch = store.registers.get(&Register::LastSearch)?;
|
||||
let lsearch = lsearch.value.to_string();
|
||||
let needle = Regex::new(lsearch.as_ref())?;
|
||||
|
||||
let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
|
||||
if needs_load {
|
||||
|
@ -706,15 +674,9 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
|||
let dir = ctx.get_search_regex_dir();
|
||||
let dir = flip.resolve(&dir);
|
||||
|
||||
let needle = match ctx.get_search_regex() {
|
||||
Some(re) => re,
|
||||
None => {
|
||||
let lsearch = store.registers.get(&Register::LastSearch)?;
|
||||
let lsearch = lsearch.value.to_string();
|
||||
|
||||
Regex::new(lsearch.as_ref())?
|
||||
},
|
||||
};
|
||||
let lsearch = store.registers.get(&Register::LastSearch)?;
|
||||
let lsearch = lsearch.value.to_string();
|
||||
let needle = Regex::new(lsearch.as_ref())?;
|
||||
|
||||
let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
|
||||
if needs_load {
|
||||
|
@ -833,7 +795,6 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
|||
HistoryAction::Checkpoint => Ok(None),
|
||||
HistoryAction::Undo(_) => Err(EditError::Failure("Nothing to undo".into())),
|
||||
HistoryAction::Redo(_) => Err(EditError::Failure("Nothing to redo".into())),
|
||||
_ => Err(EditError::Unimplemented(format!("Unknown action: {act:?}"))),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1013,12 +974,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
|||
let msg = "Cannot recall previous messages.";
|
||||
let err = EditError::Failure(msg.into());
|
||||
|
||||
return Err(err);
|
||||
},
|
||||
_ => {
|
||||
let msg = format!("Messages scrollback doesn't support {act:?}");
|
||||
let err = EditError::Unimplemented(msg);
|
||||
|
||||
return Err(err);
|
||||
},
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use matrix_sdk::{
|
|||
ruma::{OwnedRoomId, RoomId},
|
||||
};
|
||||
|
||||
use modalkit::tui::{
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
style::{Color, Style},
|
||||
|
@ -15,9 +15,11 @@ use modalkit::tui::{
|
|||
widgets::StatefulWidget,
|
||||
};
|
||||
|
||||
use modalkit::{
|
||||
widgets::list::{List, ListState},
|
||||
widgets::{TermOffset, TerminalCursor, WindowOps},
|
||||
use modalkit_ratatui::{
|
||||
list::{List, ListState},
|
||||
TermOffset,
|
||||
TerminalCursor,
|
||||
WindowOps,
|
||||
};
|
||||
|
||||
use crate::base::{IambBufferId, IambInfo, ProgramStore, RoomFocus};
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
//! Welcome Window
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use modalkit::tui::{buffer::Buffer, layout::Rect};
|
||||
use ratatui::{buffer::Buffer, layout::Rect};
|
||||
|
||||
use modalkit::{
|
||||
widgets::textbox::TextBoxState,
|
||||
widgets::WindowOps,
|
||||
widgets::{TermOffset, TerminalCursor},
|
||||
};
|
||||
use modalkit_ratatui::{textbox::TextBoxState, TermOffset, TerminalCursor, WindowOps};
|
||||
|
||||
use modalkit::editing::action::EditInfo;
|
||||
use modalkit::editing::base::{CloseFlags, WordStyle, WriteFlags};
|
||||
use modalkit::editing::completion::CompletionList;
|
||||
use modalkit::prelude::*;
|
||||
|
||||
use crate::base::{IambBufferId, IambInfo, IambResult, ProgramStore};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue