示例#1
0
        public void addGlob(NSObject sender)
        {
            var getter = new GetString{Title = "New Glob", Label = "Glob:"};
            string glob = getter.Run();
            if (!string.IsNullOrEmpty(glob))
            {
                if (!m_globs.Exists(g => g.Item1 == glob))
                {
                    m_globs.Add(Tuple.Create(glob, 0));
                    reloadData();

                    int row = m_globs.Count - 1;
                    var index = NSIndexSet.indexSetWithIndex((uint) row);
                    selectRowIndexes_byExtendingSelection(index, false);
                    scrollRowToVisible(row);

                    DoSyncPref();
                }
                else
                    Functions.NSBeep();
            }
        }
示例#2
0
        public void findLine(NSObject sender)
        {
            NSRange range = m_textView.Value.selectedRange();
            int line = m_metrics.GetLine(range.location);

            var getter = new GetString{Title = "Find Line", Label = "Line:", Text = line.ToString(), ValidText = @"\d+"};
            string text = getter.Run();
            if (text != null)
            {
                line = int.Parse(text);

                int firstOffset = m_metrics.GetLineOffset(line);
                int lastOffset = m_metrics.GetLineOffset(line + 1);
                range = new NSRange(firstOffset, lastOffset - firstOffset);

                m_textView.Value.setSelectedRange(range);
                m_textView.Value.scrollRangeToVisible(range);
                m_textView.Value.showFindIndicatorForRange(range);
            }
        }
示例#3
0
        public void Open()
        {
            string text = new GetString{Title = "Open Selection", ValidRegex = m_validator}.Run();
            if (text != null)
                text = text.Trim();

            if (!string.IsNullOrEmpty(text))
                if (!Open(text))
                    Functions.NSBeep();
        }
示例#4
0
        private object DoAsk(Script script, string prompt, object dvalue)
        {
            object result;

            if (dvalue is string)
            {
                var dialog = new GetString{Title = prompt, Label = "Value:"};
                dialog.Text = (string) dvalue;
                result = dialog.Run();
                if (result == null)
                    throw new OperationCanceledException();
            }
            else if (Equals(dvalue, true))
            {
                int button = Functions.NSRunInformationalAlertPanel(
                    NSString.Create(prompt),	// title
                    NSString.Empty,				// message,
                    NSString.Create("Yes"),		// defaultButton
                    NSString.Create("No"),		// alternateButton
                    null);								// otherButton
                result = button == Enums.NSOKButton;
            }
            else if (Equals(dvalue, false))
            {
                int button = Functions.NSRunInformationalAlertPanel(
                    NSString.Create(prompt),	// title
                    NSString.Empty,				// message,
                    NSString.Create("No"),		// defaultButton
                    NSString.Create("Yes"),		// alternateButton
                    null);								// otherButton
                result = button != Enums.NSOKButton;
            }
            else
                throw new InvalidOperationException("Default value must be a Boolean or String.");

            return result;
        }
 public void showLiveObjects(NSObject sender)
 {
     var getter = new GetString{Title = "Show Live Objects", Label = "Type:", Text = "[\\w.]+"};
     string pattern = getter.Run();
     if (pattern != null)
     {
         try
         {
             var re = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
             Func<string, object, bool> filter = (type, obj) => re.IsMatch(type);
             DoShowRoots(string.Format("({0}) Objects", pattern), filter);			// add parens so GetFileExtension doesn't get confused
         }
         catch (ArgumentException e)
         {
             Boss boss = ObjectModel.Create("Application");
             var transcript = boss.Get<ITranscript>();
             transcript.Show();
             transcript.WriteLine(Output.Error, "{0}", e.Message);
         }
     }
 }
        public void renameItem(NSObject sender)
        {
            NSIndexSet selections = m_table.selectedRowIndexes();
            if (selections.count() == 1)
            {
                uint row = selections.firstIndex();
                TableItem item = (TableItem) (m_table.itemAtRow((int) row));
                string oldName = System.IO.Path.GetFileName(item.Path);

                var get = new GetString{Title = "New Name", Label = "Name:", Text = oldName};
                string newName = get.Run();
                if (newName != null)
                    DoRename(item, newName);
            }
        }
示例#7
0
        private void DoRename(string path)
        {
            string oldName = Path.GetFileName(path);

            var get = new GetString{Title = "New Name", Label = "Name:", Text = oldName};
            string newName = get.Run();
            if (newName != null && newName != oldName)
            {
                string oldDir = Path.GetDirectoryName(path);
                Rename(path, Path.Combine(oldDir, newName));
            }
        }
示例#8
0
 private void DoCreateFile(string path)
 {
     var get = new GetString{Title = "File Name", Label = "Name:"};
     string name = get.Run();
     if (name != null)
     {
         string oldDir = Path.GetDirectoryName(path);
         using (FileStream stream = File.Create(Path.Combine(oldDir, name)))
         {
             // We just want to create it so there's nothing to do here.
         }
     }
 }
示例#9
0
 private void DoCreateDir(string path)
 {
     var get = new GetString{Title = "Directory Name", Label = "Name:"};
     string name = get.Run();
     if (name != null)
     {
         string oldDir = Path.GetDirectoryName(path);
         Unused.Value = Directory.CreateDirectory(Path.Combine(oldDir, name));
     }
 }
示例#10
0
        private void DoRename(string path)
        {
            string oldName = Path.GetFileName(path);

            var get = new GetString{Title = "New Name", Label = "Name:", Text = oldName};
            string newName = get.Run();
            if (newName != null && newName != oldName)
            {
                string oldDir = Path.GetDirectoryName(path);
                string newPath = Path.Combine(oldDir, newName);

                var result = DoCommand("move '{0}' '{1}'", path, newPath);
                if (!string.IsNullOrEmpty(result.Item2))
                    throw new InvalidOperationException(result.Item2);
            }
        }
示例#11
0
        private void DoCommit(string path)
        {
            string name = Path.GetFileName(path);

            var get = new GetString{Title = "Commit Message", Label = "Message:", Text = name + ": "};
            string message = get.Run();
            if (message != null)
            {
                var result = DoCommand("commit -m '{0}' '{1}'", message, path);
                if (!string.IsNullOrEmpty(result.Item2))
                    throw new InvalidOperationException(result.Item2);
            }
        }