Esempio n. 1
0
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            switch (key.VirtualKeyCode)
            {
            case KeyCode.F1:

                if (key.Is())
                {
                    Far.Api.ShowHelp(Far.Api.GetType().Assembly.Location, SettingsUI.HelpSettings, HelpOptions.None);
                    return(true);
                }

                break;

            case KeyCode.Delete:
            case KeyCode.F8:

                SetDefaults();
                return(true);
            }

            return(base.UIKeyPressed(key));
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            switch (key.VirtualKeyCode)
            {
            case KeyCode.F7:

                if (key.Is())
                {
                    var files = SelectedFiles;
                    if (files.Count > 0)
                    {
                        Explorer.RemoveFiles(files);
                        Update(false);
                        Redraw();
                    }
                    return(true);
                }

                break;

            case KeyCode.PageUp:

                if (key.IsCtrl())
                {
                    var efile = (SuperFile)CurrentFile;
                    if (efile == null)
                    {
                        break;
                    }

                    var panel = efile.Explorer.CreatePanel();
                    panel.PostFile(efile.File);
                    panel.OpenChild(this);
                    return(true);
                }

                break;
            }

            return(base.UIKeyPressed(key));
        }
Esempio n. 3
0
        /// <summary>
        /// Called on key in interactive.
        /// </summary>
        protected override bool KeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                return(false);
            }

            // drop pipeline now, if any
            PowerShell = null;

            // current line
            var currentLine = Editor.Line;

            switch (key.VirtualKeyCode)
            {
            case KeyCode.Tab:
            {
                if (key.Is())
                {
                    if (CommandArea() != null && EditorKit.NeedsTabExpansion(Editor))
                    {
                        InitTabExpansion();
                        EditorKit.ExpandCode(currentLine, Runspace);
                        Editor.Redraw();
                        return(true);
                    }
                }
                break;
            }

            case KeyCode.F1:
            {
                if (key.IsShift())
                {
                    Help.ShowHelpForContext();
                    return(true);
                }
                break;
            }
            }
            return(base.KeyPressed(key));
        }
Esempio n. 4
0
        /// <summary>
        /// TODO
        /// </summary>
        protected virtual bool KeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                return(false);
            }
            switch (key.VirtualKeyCode)
            {
            case KeyCode.Enter:
            {
                if (key.IsShift())
                {
                    return(DoInvoke());
                }
                break;
            }

            case KeyCode.Delete:
            {
                if (key.IsShift())
                {
                    DoDelete();
                    return(true);
                }
                break;
            }

            case KeyCode.F6:
            {
                if (key.Is())
                {
                    DoHistory();
                    return(true);
                }
                break;
            }
            }
            return(false);
        }
Esempio n. 5
0
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null) throw new ArgumentNullException("key");
            switch (key.VirtualKeyCode)
            {
                case KeyCode.F1:

                    if (key.Is())
                    {
                        Far.Api.ShowHelp(Far.Api.GetType().Assembly.Location, SettingsUI.HelpSettings, HelpOptions.None);
                        return true;
                    }

                    break;

                case KeyCode.Delete:
                case KeyCode.F8:

                    SetDefaults();
                    return true;
            }

            return base.UIKeyPressed(key);
        }
Esempio n. 6
0
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            UserWants = UserAction.None;
            try
            {
                switch (key.VirtualKeyCode)
                {
                case KeyCode.Enter:

                    if (key.Is())
                    {
                        //Far.Api.ShowError("Not implemented", new NotImplementedException("Not implemented: "+ CurrentFile.Name));

                        FarFile file = CurrentFile;
                        if (file == null)
                        {
                            break;
                        }

                        UserWants = UserAction.Enter;

                        if (file.IsDirectory && !IgnoreDirectoryFlag)
                        {
                            break;
                        }

                        var cancellation = new CancellationTokenSource();
                        var _cancel      = cancellation.Token;

                        //var ptask = new ProgressTask("test", "test-title", _cancel);
                        //var form = ptask.ShowDialog();
                        //Thread.Sleep(3000);
                        //cancellation.Cancel();
                        //form.Complete();

                        UIOpenFile(file);

                        return(true);
                    }

                    if (key.IsShift())
                    {
                        UIAttributes();
                        return(true);
                    }

                    break;

                case KeyCode.F1:

                    if (key.Is())
                    {
                        UIHelp();
                        return(true);
                    }

                    break;

                case KeyCode.F3:

                    if (key.Is())
                    {
                        if (CurrentFile == null)
                        {
                            UIExploreLocation(null);
                            //UIViewAll();
                            return(true);
                        }

                        /*
                         * if (CurrentFile.IsDirectory)
                         * {
                         *  Explorer.CanExploreLocation = true;
                         *  break;
                         * }
                         *
                         * Explorer.CanExploreLocation = false;
                         */
                        break;
                    }

                    if (key.IsShift())
                    {
                        //ShowMenu();
                        return(true);
                    }

                    break;

                /*
                 * case KeyCode.F5:
                 *
                 *  if (key.Is())
                 *  {
                 *      if (CurrentFile == null)
                 *      {
                 *          //UIViewAll();
                 *          return true;
                 *      }
                 *
                 *      Log.Source.TraceInformation("Tried to copy this file: {0}\\{1}", CurrentLocation, CurrentFile.Name);
                 *
                 *      Log.Source.TraceInformation("Far.Api.Panel2.IsPlugin = {0}", Far.Api.Panel2.IsPlugin ? "true" : "false");
                 *      Log.Source.TraceInformation("Far.Api.Panel2.CurrentFile = {0}", Far.Api.Panel2.CurrentFile);
                 *      Log.Source.TraceInformation("Far.Api.Panel2.CurrentDirectory = {0}", Far.Api.Panel2.CurrentDirectory);
                 *
                 *      if (Far.Api.Panel2.IsPlugin)
                 *      {
                 *          // How to copy files to plugins??
                 *          return true;
                 *      }
                 *
                 *      if (Far.Api.Panel2.CurrentDirectory == null)
                 *      {
                 *          // how can it be?
                 *          return true;
                 *      }
                 *
                 *      var item = ((CurrentFile.Data as Hashtable)["fsitem"] as FSItem);
                 *      var path = Path.Combine(Far.Api.Panel2.CurrentDirectory, item.Name);
                 *
                 *      var form = new Tools.ProgressForm();
                 *      form.Activity = "Downloading...";
                 *      form.Title = "Amazon Cloud Drive - File Download Progress";
                 *      form.CanCancel = true;
                 *      form.SetProgressValue(0, item.Length);
                 *      form.Canceled += (object sender, EventArgs e) =>
                 *      {
                 *          form.Close();
                 *      };
                 *
                 *      Task task = (Explorer as ACDExplorer).Client.DownloadFile(item, path, form);
                 *      var cs = new CancellationTokenSource();
                 *      var token = cs.Token;
                 *      / *
                 *      token.Register(() =>
                 *      {
                 *          form.Close();
                 *      });* /
                 *      var _task = Task.Factory.StartNew(() =>
                 *      {
                 *          form.Show();
                 *      }, token);
                 *      task.Wait();
                 *
                 *      break;
                 *  }
                 *
                 *  if (key.IsShift())
                 *  {
                 *      //ShowMenu();
                 *      return true;
                 *  }
                 *
                 *  break;
                 */
                case KeyCode.PageDown:

                    if (key.IsCtrl())
                    {
                        UIOpenFileMembers();
                        return(true);
                    }

                    break;

                case KeyCode.A:

                    if (key.IsCtrl())
                    {
                        UIAttributes();
                        return(true);
                    }

                    break;

                case KeyCode.G:

                    if (key.IsCtrl())
                    {
                        UIApply();
                        return(true);
                    }

                    break;

                case KeyCode.M:

                    if (key.IsCtrlShift())
                    {
                        UIMode();
                        return(true);
                    }

                    break;

                case KeyCode.S:

                    //! Mantis#2635 Ignore if auto-completion menu is opened
                    if (key.IsCtrl() && Far.Api.Window.Kind != WindowKind.Menu)
                    {
                        SaveData();
                        return(true);
                    }

                    break;

                case KeyCode.R:

                    if (key.IsCtrl())
                    {
                        CacheStorage.RemoveItems(Far.Api.Panel.CurrentDirectory);
                    }

                    break;
                }

                // base
                return(base.UIKeyPressed(key));
            }
            finally
            {
                UserWants = UserAction.None;
            }
        }
Esempio n. 7
0
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            UserWants = UserAction.None;
            try
            {
                switch (key.VirtualKeyCode)
                {
                case KeyCode.Enter:

                    if (key.Is())
                    {
                        FarFile file = CurrentFile;
                        if (file == null)
                        {
                            break;
                        }

                        UserWants = UserAction.Enter;

                        if (file.IsDirectory && !IgnoreDirectoryFlag)
                        {
                            break;
                        }

                        UIOpenFile(file);
                        return(true);
                    }

                    if (key.IsShift())
                    {
                        UIAttributes();
                        return(true);
                    }

                    break;

                case KeyCode.F1:

                    if (key.Is())
                    {
                        UIHelp();
                        return(true);
                    }

                    break;

                case KeyCode.F3:

                    if (key.Is())
                    {
                        if (CurrentFile == null)
                        {
                            UIViewAll();
                            return(true);
                        }
                        break;
                    }

                    if (key.IsShift())
                    {
                        ShowMenu();
                        return(true);
                    }

                    break;

                case KeyCode.PageDown:

                    if (key.IsCtrl())
                    {
                        UIOpenFileMembers();
                        return(true);
                    }

                    break;

                case KeyCode.A:

                    if (key.IsCtrl())
                    {
                        UIAttributes();
                        return(true);
                    }

                    break;

                case KeyCode.G:

                    if (key.IsCtrl())
                    {
                        UIApply();
                        return(true);
                    }

                    break;

                case KeyCode.M:

                    if (key.IsCtrlShift())
                    {
                        UIMode();
                        return(true);
                    }

                    break;

                case KeyCode.S:

                    //! Mantis#2635 Ignore if auto-completion menu is opened
                    if (key.IsCtrl() && Far.Api.Window.Kind != WindowKind.Menu)
                    {
                        SaveData();
                        return(true);
                    }

                    break;
                }

                // base
                return(base.UIKeyPressed(key));
            }
            finally
            {
                UserWants = UserAction.None;
            }
        }
Esempio n. 8
0
        /// <inheritdoc/>
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null) throw new ArgumentNullException("key");
            switch (key.VirtualKeyCode)
            {
                case KeyCode.F7:

                    if (key.Is())
                    {
                        var files = SelectedFiles;
                        if (files.Count > 0)
                        {
                            Explorer.RemoveFiles(files);
                            Update(false);
                            Redraw();
                        }
                        return true;
                    }

                    break;

                case KeyCode.PageUp:

                    if (key.IsCtrl())
                    {
                            var efile = (SuperFile)CurrentFile;
                            if (efile == null)
                                break;

                            var panel = efile.Explorer.CreatePanel();
                            panel.PostFile(efile.File);
                            panel.OpenChild(this);
                            return true;
                    }

                    break;
            }

            return base.UIKeyPressed(key);
        }
Esempio n. 9
0
        /// <inheritdoc/>
        public override bool UIKeyPressed(KeyInfo key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            switch (key.VirtualKeyCode)
            {
            case KeyCode.LeftArrow:
            {
                if (!key.Is() && !key.IsAlt() || Far.Api.CommandLine.Length > 0)
                {
                    break;
                }

                FarFile file = CurrentFile;
                if (file == null)
                {
                    break;
                }

                TreeFile node = (TreeFile)file;
                if (node._State == 1)
                {
                    // reset
                    if (key.IsAlt())
                    {
                        node.ChildFiles.Clear();
                        node._State = 0;
                        UpdateRedraw(false);
                        return(true);
                    }

                    // collapse
                    OpenFile(file);
                }
                else if (node.Parent != null)
                {
                    PostFile(node.Parent);
                    Redraw();
                }

                return(true);
            }

            case KeyCode.RightArrow:
            {
                if (!key.Is() && !key.IsAlt() || Far.Api.CommandLine.Length > 0)
                {
                    break;
                }

                FarFile file = CurrentFile;
                if (file == null)
                {
                    break;
                }

                TreeFile node = (TreeFile)file;
                if (node != null && node._State != 1 && node.IsNode)
                {
                    // reset
                    if (key.IsAlt())
                    {
                        node.ChildFiles.Clear();
                        node._State = 0;
                    }

                    // open
                    OpenFile(file);
                }
                else
                {
                    // go to next
                    Redraw(CurrentIndex + 1, -1);
                }

                return(true);
            }
            }

            // base
            return(base.UIKeyPressed(key));
        }