Exemplo n.º 1
0
 protected override void Update(CommandArrayInfo ainfo)
 {
     MonoDevelop.Ide.Gui.Document doc = IdeApp.Workbench.ActiveDocument;
     if (doc != null)
     {
         SourceEditorView view = IdeApp.Workbench.ActiveDocument.GetContent <SourceEditorView>();
         if (view != null)
         {
             DocumentLocation location = view.TextEditor.Caret.Location;
             if (location.IsEmpty)
             {
                 return;
             }
             DocumentLine line = view.Document.GetLine(location.Line);
             if (line == null || line.Markers == null)
             {
                 return;
             }
             foreach (TextLineMarker marker in line.Markers)
             {
                 UrlMarker urlMarker = marker as UrlMarker;
                 if (urlMarker != null)
                 {
                     if (urlMarker.StartColumn <= location.Column && location.Column < urlMarker.EndColumn)
                     {
                         ainfo.Add(urlMarker.UrlType == UrlType.Email ? GettextCatalog.GetString("_Write an e-mail to...") : GettextCatalog.GetString("_Open URL..."), urlMarker);
                         ainfo.AddSeparator();
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// The url has been read to here. Remember the url if its valid, and reset state.
        /// </summary>
        /// <param name="state">The state indicating if this url is valid. If its valid it will be added to the list of urls.</param>
        /// <returns>True if the url was valid</returns>
        private bool ReadEnd(ReadEndState state)
        {
            //if the url is valid and greater then 0
            if (state == ReadEndState.ValidUrl && _buffer.Length > 0)
            {
                //get the last character. if its a quote, cut it off.
                var len        = _buffer.Length;
                var startIndex = len - 1;
                if (_quoteStart && _buffer[startIndex] == '\"')
                {
                    _buffer.Remove(startIndex, len - startIndex);
                }

                //Add the url to the list of good urls.
                if (_buffer.Length > 0)
                {
                    _currentUrlMarker.SetOriginalUrl(_buffer.ToString());
                    _urlList.Add(_currentUrlMarker.CreateUrl());
                }
            }

            //clear out the buffer.
            _buffer.Remove(0, _buffer.Length);

            //reset the state of internal objects.
            _quoteStart       = false;
            _hasScheme        = false;
            _dontMatchIpv6    = false;
            _currentUrlMarker = new UrlMarker();

            //return true if valid.
            return(state == ReadEndState.ValidUrl);
        }
Exemplo n.º 3
0
        public void TestUrlMarkers(string testString, string scheme, string username, string password, string host, int port,
                                   string path, string query, string fragment, int[] indices)
        {
            var urlMarker = new UrlMarker();

            urlMarker.SetOriginalUrl(testString);
            urlMarker.SetIndices(indices);
            var url = urlMarker.CreateUrl();

            Assert.Equal(url.GetHost(), host /*, "host, " + testString*/);
            Assert.Equal(url.GetPath(), path /*, "path, " + testString*/);
            Assert.Equal(url.GetScheme(), scheme /*, "scheme, " + testString*/);
            Assert.Equal(url.GetUsername(), username /*, "username, " + testString*/);
            Assert.Equal(url.GetPassword(), password /*, "password, " + testString*/);
            Assert.Equal(url.GetPort(), port /*, "port, " + testString*/);
            Assert.Equal(url.GetQuery(), query /*, "query, " + testString*/);
            Assert.Equal(url.GetFragment(), fragment /*, "fragment, " + testString*/);
        }
Exemplo n.º 4
0
        protected override void Run(object data)
        {
            UrlMarker urlMarker = data as UrlMarker;

            if (data == null)
            {
                return;
            }
            try {
                if (urlMarker.UrlType == UrlType.Email)
                {
                    System.Diagnostics.Process.Start("mailto:" + urlMarker.Url);
                }
                else
                {
                    System.Diagnostics.Process.Start(urlMarker.Url);
                }
            } catch (Exception) {
                MessageService.ShowError(GettextCatalog.GetString("Could not open the url {0}", urlMarker.Url));
            }
        }
Exemplo n.º 5
0
 public NormalizedUrl(UrlMarker urlMarker) : base(urlMarker)
 {
 }