fn handle_cmd(&mut self, cmd: Command) {
        use Target as T;
        match cmd.target() {
            // these are handled the same no matter where they come from
            _ if cmd.is(sys_cmd::QUIT_APP) => self.quit(),
            #[cfg(target_os = "macos")]
            _ if cmd.is(sys_cmd::HIDE_APPLICATION) => self.hide_app(),
            #[cfg(target_os = "macos")]
            _ if cmd.is(sys_cmd::HIDE_OTHERS) => self.hide_others(),
            _ if cmd.is(sys_cmd::NEW_WINDOW) => {
                if let Err(e) = self.new_window(cmd) {
                    tracing::error!("failed to create window: '{}'", e);
                }
            }
            _ if cmd.is(sys_cmd::NEW_SUB_WINDOW) => {
                if let Err(e) = self.new_sub_window(cmd) {
                    tracing::error!("failed to create sub window: '{}'", e);
                }
            }
            _ if cmd.is(sys_cmd::CLOSE_ALL_WINDOWS) => self.request_close_all_windows(),
            T::Window(id) if cmd.is(sys_cmd::INVALIDATE_IME) => self.invalidate_ime(cmd, id),
            // these should come from a window
            // FIXME: we need to be able to open a file without a window handle
            T::Window(id) if cmd.is(sys_cmd::SHOW_OPEN_PANEL) => self.show_open_panel(cmd, id),
            T::Window(id) if cmd.is(sys_cmd::SHOW_SAVE_PANEL) => self.show_save_panel(cmd, id),
            T::Window(id) if cmd.is(sys_cmd::CONFIGURE_WINDOW) => self.configure_window(cmd, id),
            T::Window(id) if cmd.is(sys_cmd::CLOSE_WINDOW) => {
                if !self.inner.borrow_mut().dispatch_cmd(cmd).is_handled() {
                    self.request_close_window(id);
                }
            }
            T::Window(id) if cmd.is(sys_cmd::SHOW_WINDOW) => self.show_window(id),
            T::Window(id) if cmd.is(sys_cmd::PASTE) => self.do_paste(id),
            _ if cmd.is(sys_cmd::CLOSE_WINDOW) => {
                tracing::warn!("CLOSE_WINDOW command must target a window.")
            }
            _ if cmd.is(sys_cmd::SHOW_WINDOW) => {
                tracing::warn!("SHOW_WINDOW command must target a window.")
            }
            _ if cmd.is(sys_cmd::SHOW_OPEN_PANEL) => {
                tracing::warn!("SHOW_OPEN_PANEL command must target a window.")
            }
            _ => {
                self.inner.borrow_mut().dispatch_cmd(cmd);
            }
        }
    }
/// Handle a command. Top level commands (e.g. for creating and destroying
/// windows) have their logic here; other commands are passed to the window.
Handle a command. Top level commands  have their logic here; other commands are passed to the window.
Handle a command . Top level commands have their logic here ; other commands are passed to the window .
fn handle_cmd(&mut self, cmd: Command) {
        use Target as T;
        match cmd.target() {
            // these are handled the same no matter where they come from
            _ if cmd.is(sys_cmd::QUIT_APP) => self.quit(),
            #[cfg(target_os = "macos")]
            _ if cmd.is(sys_cmd::HIDE_APPLICATION) => self.hide_app(),
            #[cfg(target_os = "macos")]
            _ if cmd.is(sys_cmd::HIDE_OTHERS) => self.hide_others(),
            _ if cmd.is(sys_cmd::NEW_WINDOW) => {
                if let Err(e) = self.new_window(cmd) {
                    tracing::error!("failed to create window: '{}'", e);
                }
            }
            _ if cmd.is(sys_cmd::NEW_SUB_WINDOW) => {
                if let Err(e) = self.new_sub_window(cmd) {
                    tracing::error!("failed to create sub window: '{}'", e);
                }
            }
            _ if cmd.is(sys_cmd::CLOSE_ALL_WINDOWS) => self.request_close_all_windows(),
            T::Window(id) if cmd.is(sys_cmd::INVALIDATE_IME) => self.invalidate_ime(cmd, id),
            // these should come from a window
            // FIXME: we need to be able to open a file without a window handle
            T::Window(id) if cmd.is(sys_cmd::SHOW_OPEN_PANEL) => self.show_open_panel(cmd, id),
            T::Window(id) if cmd.is(sys_cmd::SHOW_SAVE_PANEL) => self.show_save_panel(cmd, id),
            T::Window(id) if cmd.is(sys_cmd::CONFIGURE_WINDOW) => self.configure_window(cmd, id),
            T::Window(id) if cmd.is(sys_cmd::CLOSE_WINDOW) => {
                if !self.inner.borrow_mut().dispatch_cmd(cmd).is_handled() {
                    self.request_close_window(id);
                }
            }
            T::Window(id) if cmd.is(sys_cmd::SHOW_WINDOW) => self.show_window(id),
            T::Window(id) if cmd.is(sys_cmd::PASTE) => self.do_paste(id),
            _ if cmd.is(sys_cmd::CLOSE_WINDOW) => {
                tracing::warn!("CLOSE_WINDOW command must target a window.")
            }
            _ if cmd.is(sys_cmd::SHOW_WINDOW) => {
                tracing::warn!("SHOW_WINDOW command must target a window.")
            }
            _ if cmd.is(sys_cmd::SHOW_OPEN_PANEL) => {
                tracing::warn!("SHOW_OPEN_PANEL command must target a window.")
            }
            _ => {
                self.inner.borrow_mut().dispatch_cmd(cmd);
            }
        }
    }
fn handle_cmd ( & mut self , cmd : Command ) { use Target as T ; match cmd . target ( ) { // these are handled the same no matter where they come from _ if cmd . is ( sys_cmd :: QUIT_APP ) => self . quit ( ) , # [ cfg ( target_os " " ) ] _ if cmd . is ( sys_cmd :: HIDE_APPLICATION ) => self . hide_app ( ) , # [ cfg ( target_os " " ) ] _ if cmd . is ( sys_cmd :: HIDE_OTHERS ) => self . hide_others ( ) , _ if cmd . is ( sys_cmd :: NEW_WINDOW ) => { if let Err ( e ) = self . new_window ( cmd ) { tracing :: error ! ( " " e ) ; } } _ if cmd . is ( sys_cmd :: NEW_SUB_WINDOW ) => { if let Err ( e ) = self . new_sub_window ( cmd ) { tracing :: error ! ( " " e ) ; } } _ if cmd . is ( sys_cmd :: CLOSE_ALL_WINDOWS ) => self . request_close_all_windows ( ) , T :: Window ( id ) if cmd . is ( sys_cmd :: INVALIDATE_IME ) => self . invalidate_ime ( cmd , id ) , // these should come from a window // FIXME: we need to be able to open a file without a window handle T :: Window ( id ) if cmd . is ( sys_cmd :: SHOW_OPEN_PANEL ) => self . show_open_panel ( cmd , id ) , T :: Window ( id ) if cmd . is ( sys_cmd :: SHOW_SAVE_PANEL ) => self . show_save_panel ( cmd , id ) , T :: Window ( id ) if cmd . is ( sys_cmd :: CONFIGURE_WINDOW ) => self . configure_window ( cmd , id ) , T :: Window ( id ) if cmd . is ( sys_cmd :: CLOSE_WINDOW ) => { if ! self . inner . borrow_mut ( ) . dispatch_cmd ( cmd ) . is_handled ( ) { self . request_close_window ( id ) ; } } T :: Window ( id ) if cmd . is ( sys_cmd :: SHOW_WINDOW ) => self . show_window ( id ) , T :: Window ( id ) if cmd . is ( sys_cmd :: PASTE ) => self . do_paste ( id ) , _ if cmd . is ( sys_cmd :: CLOSE_WINDOW ) => { tracing :: warn ! ( " " ) } _ if cmd . is ( sys_cmd :: SHOW_WINDOW ) => { tracing :: warn ! ( " " ) } _ if cmd . is ( sys_cmd :: SHOW_OPEN_PANEL ) => { tracing :: warn ! ( " " ) } _ => { self . inner . borrow_mut ( ) . dispatch_cmd ( cmd ) ; } } }
Handle a command.
Handle a command .
&mut self
cmd
Command
&mut self
cmd
Command