/// <summary>
        /// Handles background jobs menu item call in panels menu.
        /// </summary>
        public override void Invoke(object sender, ModuleToolEventArgs e)
        {
            if (null == Far.Api.Panel)
            {
                Far.Api.Message(Strings.ErrorNoPanel,
                                Strings.ErrorHeader,
                                MessageOptions.Error | MessageOptions.Ok);
                return;
            }

            if (null == Far.Api.Panel.SelectedFiles)
            {
                Far.Api.Message(Strings.ErrorNoFilesSelected,
                                Strings.ErrorHeader,
                                MessageOptions.Error | MessageOptions.Ok);
                return;
            }

            ShowOperationsMenu();
        }
Beispiel #2
0
        internal static void Show(object sender, ModuleToolEventArgs e)
        {
            //! NOTE: do sync for item handlers
            string currentDirectory = A.Psf.SyncPaths();
            try
            {
                // create once
                if (_menuDialog == null)
                    Create();

                IMenu menu;

                switch (e.From)
                {
                    case ModuleToolOptions.Dialog: menu = _menuDialog; break;
                    case ModuleToolOptions.Editor: menu = _menuEditor; break;
                    case ModuleToolOptions.Panels: menu = _menuPanels; break;
                    case ModuleToolOptions.Viewer: menu = _menuViewer; break;
                    default: return;
                }

                // reset, lock and show
                menu.Selected = -1;
                menu.Lock();
                menu.Show();
            }
            catch (PipelineStoppedException)
            {
                // Ignore this exception, a user has halted, e.g. on menu action:
                // Remove-Variable Far -Confirm
                // -- Confirm dialog -- press [Esc] -- click [Halt] -- we are in here
            }
            finally
            {
                A.SetCurrentDirectoryFinally(currentDirectory);
            }
        }
Beispiel #3
0
        public override void Invoke(object sender, ModuleToolEventArgs e)
        {
            FarPodContext.Init(Manager);

            new DeviceExplorer().OpenPanel();
        }
Beispiel #4
0
 /// <summary>
 /// This method is called when the tool menu item is invoked.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The arguments.</param>
 public abstract void Invoke(object sender, ModuleToolEventArgs e);
Beispiel #5
0
 public override void Invoke(object sender, ModuleToolEventArgs e)
 {
     IEditor editor = Far.Net.Editor;
     if (editor.SelectionExists)
         editor.SetSelectedText(Regex.Replace(editor.GetSelectedText("\r"), @"\\([\\""])", "$1"));
 }
Beispiel #6
0
 internal void OnOpen(object sender, ModuleToolEventArgs e)
 {
     UI.ActorMenu.Show(sender, e);
 }
Beispiel #7
0
        public override void Invoke(object sender, ModuleToolEventArgs e)
        {
            var panel = Far.Api.Panel;
            if (panel.IsPlugin || panel.Kind != PanelKind.File)
                return;

            var path = panel.CurrentDirectory;

            var run = new SizeRun();
            if (!run.Run(Directory.GetDirectories(path), Directory.GetFiles(path)))
                return;

            var sb = new StringBuilder();
            foreach (var it in run.Errors)
                sb.AppendLine(it.Message);
            if (sb.Length > 0)
                Message(sb.ToString());

            var sorted = run.Result.OrderBy(x => x.Size).ToList();
            if (sorted.Count == 0)
                return;

            var totalSize = run.Result.Sum(x => x.Size);
            var title = Kit.FormatSize(totalSize, path);

            var maxSizeToShow = sorted[sorted.Count - 1].Size / HIDDEN_FACTOR;
            long sumHiddenSizes = 0;
            int index = 0;
            for (; index < sorted.Count; ++index)
            {
                if (sorted[index].Size < maxSizeToShow || sorted.Count - index > MAX_ITEM_COUNT)
                    sumHiddenSizes += sorted[index].Size;
                else
                    break;
            }
            if (index > 0)
                sorted.RemoveRange(0, index);
            if (sumHiddenSizes > 0)
                sorted.Insert(0, new FolderItem() { Name = string.Empty, Size = sumHiddenSizes });

            var result = FolderChartForm.Show(title, sorted, new WindowWrapper(Far.Api.UI.MainWindowHandle));
            if (result == null)
                return;

            var path2 = Path.Combine(path, result);
            if (Directory.Exists(path2))
            {
                panel.CurrentDirectory = path2;
            }
            else if (File.Exists(path2))
            {
                bool ok = panel.GoToName(result, false);
                if (!ok)
                    Message(path2 + " exists but it is not in the panel.");
            }
            else
            {
                Message(path2 + " does not exist.");
            }

            panel.Redraw();
        }
Beispiel #8
0
 /// <summary>
 /// This method is called when the tool menu item is invoked.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The arguments.</param>
 public abstract void Invoke(object sender, ModuleToolEventArgs e);