diff options
Diffstat (limited to 'src/queue.rs')
-rw-r--r-- | src/queue.rs | 164 |
1 files changed, 82 insertions, 82 deletions
diff --git a/src/queue.rs b/src/queue.rs index 6c781e2b..cac4ab9e 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -4,109 +4,109 @@ use bitflags::bitflags; use std::{cell::RefCell, collections::VecDeque, rc::Rc}; bitflags! { - /// flags defining what part of the app need to update - pub struct NeedsUpdate: u32 { - /// app::update - const ALL = 0b001; - /// diff may have changed (app::update_diff) - const DIFF = 0b010; - /// commands might need updating (app::update_commands) - const COMMANDS = 0b100; - /// branches have changed - const BRANCHES = 0b1000; - } + /// flags defining what part of the app need to update + pub struct NeedsUpdate: u32 { + /// app::update + const ALL = 0b001; + /// diff may have changed (app::update_diff) + const DIFF = 0b010; + /// commands might need updating (app::update_commands) + const COMMANDS = 0b100; + /// branches have changed + const BRANCHES = 0b1000; + } } /// data of item that is supposed to be reset pub struct ResetItem { - /// path to the item (folder/file) - pub path: String, - /// are talking about a folder here? otherwise it's a single file - pub is_folder: bool, + /// path to the item (folder/file) + pub path: String, + /// are talking about a folder here? otherwise it's a single file + pub is_folder: bool, } /// pub enum Action { - Reset(ResetItem), - ResetHunk(String, u64), - ResetLines(String, Vec<DiffLinePosition>), - StashDrop(CommitId), - StashPop(CommitId), - DeleteBranch(String, bool), - DeleteTag(String), - ForcePush(String, bool), - PullMerge { incoming: usize, rebase: bool }, - AbortMerge, + Reset(ResetItem), + ResetHunk(String, u64), + ResetLines(String, Vec<DiffLinePosition>), + StashDrop(CommitId), + StashPop(CommitId), + DeleteBranch(String, bool), + DeleteTag(String), + ForcePush(String, bool), + PullMerge { incoming: usize, rebase: bool }, + AbortMerge, } /// pub enum InternalEvent { - /// - ConfirmAction(Action), - /// - ConfirmedAction(Action), - /// - ShowErrorMsg(String), - /// - Update(NeedsUpdate), - /// - StatusLastFileMoved, - /// open commit msg input - OpenCommit, - /// - PopupStashing(StashingOptions), - /// - TabSwitch, - /// - InspectCommit(CommitId, Option<CommitTags>), - /// - SelectCommitInRevlog(CommitId), - /// - TagCommit(CommitId), - /// - Tags, - /// - BlameFile(String), - /// - CreateBranch, - /// - RenameBranch(String, String), - /// - SelectBranch, - /// - OpenExternalEditor(Option<String>), - /// - Push(String, bool, bool), - /// - Pull(String), - /// - PushTags, - /// - OpenFileTree(CommitId), + /// + ConfirmAction(Action), + /// + ConfirmedAction(Action), + /// + ShowErrorMsg(String), + /// + Update(NeedsUpdate), + /// + StatusLastFileMoved, + /// open commit msg input + OpenCommit, + /// + PopupStashing(StashingOptions), + /// + TabSwitch, + /// + InspectCommit(CommitId, Option<CommitTags>), + /// + SelectCommitInRevlog(CommitId), + /// + TagCommit(CommitId), + /// + Tags, + /// + BlameFile(String), + /// + CreateBranch, + /// + RenameBranch(String, String), + /// + SelectBranch, + /// + OpenExternalEditor(Option<String>), + /// + Push(String, bool, bool), + /// + Pull(String), + /// + PushTags, + /// + OpenFileTree(CommitId), } /// single threaded simple queue for components to communicate with each other #[derive(Clone)] pub struct Queue { - data: Rc<RefCell<VecDeque<InternalEvent>>>, + data: Rc<RefCell<VecDeque<InternalEvent>>>, } impl Queue { - pub fn new() -> Self { - Self { - data: Rc::new(RefCell::new(VecDeque::new())), - } - } + pub fn new() -> Self { + Self { + data: Rc::new(RefCell::new(VecDeque::new())), + } + } - pub fn push(&self, ev: InternalEvent) { - self.data.borrow_mut().push_back(ev); - } + pub fn push(&self, ev: InternalEvent) { + self.data.borrow_mut().push_back(ev); + } - pub fn pop(&self) -> Option<InternalEvent> { - self.data.borrow_mut().pop_front() - } + pub fn pop(&self) -> Option<InternalEvent> { + self.data.borrow_mut().pop_front() + } - pub fn clear(&self) { - self.data.borrow_mut().clear(); - } + pub fn clear(&self) { + self.data.borrow_mut().clear(); + } } |