Esempio n. 1
0
        public void Init(TextController controller)
        {
            Contract.Requires(controller != null, "controller is null");

            m_controller = controller;
            DoReset();
        }
Esempio n. 2
0
        public Boss Create(string bossName)
        {
            var controller = new TextController(bossName);
            controller.autorelease();

            controller.Text = string.Empty;
            controller.Open();

            return controller.Boss;
        }
Esempio n. 3
0
		public void MakeWindowControllers(string bossName)
		{
			m_controller = new TextController(bossName);
			addWindowController(m_controller);
			m_controller.autorelease();
			
			DoResetURL(fileURL());
			m_controller.OnPathChanged();
			
			if (NSObject.IsNullOrNil(m_text))
			{
				m_controller.Text = string.Empty;		// m_text will be null if we're opening a new doc
			}
			else
			{
				m_controller.RichText = m_text;
				m_text.release();
				m_text = null;
			}
			m_controller.Open();
		}
Esempio n. 4
0
        public ApplyStyles(TextController controller, NSTextView text)
        {
            Contract.Requires(text.textStorage().layoutManagers().count() == 1, "expected one layout not " + text.textStorage().layoutManagers().count());

            m_controller = controller;
            m_storage = text.textStorage();
            m_layout = m_storage.layoutManagers().objectAtIndex(0).To<NSLayoutManager>();

            m_current = new CurrentStyles(controller, m_storage);

            Broadcaster.Register("tab stops changed", this);
            Broadcaster.Register("selected line color changed", this);
            Broadcaster.Register("computed style runs", this);
            Broadcaster.Register("text changed", this);

            if (ms_selectedLineColor == null)
                DoSetTempAttrs();

            DoResetTabStops();
            DoApplyParagraphStyles(true);

            ActiveObjects.Add(this);
        }
Esempio n. 5
0
 public RestoreViewState(TextController controller)
 {
     m_controller = controller;
     ActiveObjects.Add(this);
 }
Esempio n. 6
0
        public CurrentStyles(TextController controller, NSTextStorage storage)
        {
            m_controller = controller;
            m_storage = storage;
            m_stylesWriteTime = DateTime.Now;

            Broadcaster.Register("text spaces color changed", this);
            Broadcaster.Register("text tabs color changed", this);

            string path = Path.GetDirectoryName(ms_stylesPath);
            m_watcher = new DirectoryWatcher(path, TimeSpan.FromMilliseconds(250));
            m_watcher.Changed += this.DoFilesChanged;

            ActiveObjects.Add(this);
        }
Esempio n. 7
0
        private bool DoSelectPreviousIdentifier(TextController controller)
        {
            NSRange range = selectedRange();

            NSRange previous;
            if (controller.Language != null && controller.Language.Name == "CsLanguage")
            {
                var tokens = m_boss.Get<ISearchTokens>();
                previous = tokens.GetPreviousIdentifier(range.location);
            }
            else
            {
                // If we're in the middle of an identifier then skip past it.
                previous.location = range.location;
                previous.location -= DoSkip(previous.location, -1, (c) => char.IsLetterOrDigit(c) || c == '_');

                // Skip to the end of the previous identifier.
                previous.location -= DoSkip(previous.location, -1, (c) => !char.IsLetterOrDigit(c) && c != '_');

                // Get the length of the identifier.
                previous.length = DoSkip(previous.location, -1, (c) => char.IsLetterOrDigit(c) || c == '_');	// TODO: this will find numbers
                previous.location -= previous.length - 1;
            }

            if (previous.length > 0)
            {
                previous = selectionRangeForProposedRange_granularity(previous, Enums.NSSelectByWord);
                setSelectedRange(previous);
                scrollRangeToVisible(previous);
            }

            return true;
        }
Esempio n. 8
0
        // Another possibility here is that after completing a method we could set the
        // find text to a regex which can be used to select the next identifier. This
        // would allow command-G to be used instead of option-tab which might be
        // a bit more natural. Although it would also zap the user's find text and screw
        // up the find history popup.
        private bool DoSelectNextIdentifier(TextController controller)
        {
            NSRange range = selectedRange();

            NSRange next;
            if (controller.Language != null && controller.Language.Name == "CsLanguage")
            {
                // TODO: ISearchTokens should probably be moved into the language boss.
                // It might also be worthwhile to split it into multiple interfaces.
                var tokens = m_boss.Get<ISearchTokens>();
                next = tokens.GetNextIdentifier(range.location + range.length);
            }
            else
            {
                // If we're in the middle of an identifier then skip past it.
                next.location = range.location + range.length;
                next.location += DoSkip(next.location, +1, (c) => char.IsLetterOrDigit(c) || c == '_');

                // Skip to the start of the next identifier.
                next.location += DoSkip(next.location, +1, (c) => !char.IsLetter(c) && c != '_');

                // Get the length of the identifier.
                next.length = DoSkip(next.location, +1, (c) => char.IsLetterOrDigit(c) || c == '_');
            }

            if (next.length > 0)
            {
                next = selectionRangeForProposedRange_granularity(next, Enums.NSSelectByWord);
                setSelectedRange(next);
                scrollRangeToVisible(next);
            }

            return true;	// if we don't return true then NSTextView adds some weird indent
        }
Esempio n. 9
0
        public void onOpened(TextController controller)
        {
            m_boss = controller.Boss;
            m_autoComplete = m_boss.Get<IAutoComplete>();
            setTypingAttributes(CurrentStyles.DefaultAttributes);
            setAutomaticTextReplacementEnabled(false);

            if (m_boss.Has<ITooltip>())
            {
                m_tooltip = m_boss.Get<ITooltip>();
                m_timer = new System.Threading.Timer((object state) =>
                {
                    NSApplication.sharedApplication().BeginInvoke(this.DoShowTooltip);
                });
            }
        }
Esempio n. 10
0
        public void onClosing(TextController controller)
        {
            if (m_tooltipWindow != null)
            {
                m_tooltipWindow.Close();
                m_tooltipWindow = null;
            }
            if (m_timer != null)
                m_timer.Dispose();

            m_autoComplete = null;		// note that these won't be GCed if we don't null them out
            m_boss = null;
        }