コード例 #1
0
        protected override ParsingResult ParseSource(ILogSource source, LogReaderSettings settings, ParsingResult result = null)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            TextStorage storage = new TextStorage();

            result = result ?? new ParsingResult();
            var log = (IEnumerable <string[]>)source;

            if (!(source is AzureLogSource))
            {
                throw new ApplicationException("Non Azure log source was tried to be parsed by Azure log reader");
            }

            foreach (var lines in log)
            {
                var logEntry = logParser.ParseLine(lines[0], new DateTime(long.Parse(lines[1])), storage);
                if (logEntry != null)
                {
                    logEntry = AnalyzeLog(logEntry, storage);
                    result.AddToGroupAll(logEntry);
                }
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Performs the formatting command on the currectly selected range of text.
        /// </summary>
        /// <param name="command">The <see cref="AppKit.TextKit.Formatter.LanguageFormatCommand"/> to apply.</param>
        public void PerformFormattingCommand(LanguageFormatCommand command)
        {
            NSRange range = SelectedRange;

            // Apply to start of line?
            if (command.Postfix == "")
            {
                // Yes, find start
                range = Formatter.FindLineBoundries(TextStorage.Value, SelectedRange);
            }

            // Yes, get selected text
            var location = range.Location;
            var line     = TextStorage.Value.Substring((int)range.Location, (int)range.Length);

            // Apply command
            var output = command.Prefix;

            output += line;
            output += command.Postfix;
            TextStorage.BeginEditing();
            Replace(range, output);
            TextStorage.EndEditing();
            Formatter.HighlightSyntaxRegion(TextStorage.Value, range);
        }
コード例 #3
0
        private static void DrawText(Rect pos, string text, int scale, Color color, bool center)
        {
            string identifier = $"{pos.y}_{scale}_{text}_{center}_{color.r}";

            TextStorage currentItem;

            if (!m_textStorage.Keys.Contains(identifier))
            {
                GUIStyle newStyle = new GUIStyle()
                {
                    alignment = (center ? TextAnchor.MiddleCenter : TextAnchor.MiddleLeft),
                    fontSize  = scale,
                    fontStyle = FontStyle.Normal
                };

                newStyle.richText         = true;
                newStyle.normal.textColor = color;

                currentItem = new TextStorage()
                {
                    Text     = text,
                    Style    = newStyle,
                    Position = pos,
                };

                m_textStorage.Add(identifier, currentItem);
            }
            else
            {
                currentItem = m_textStorage[identifier];
            }

            GUI.Label(currentItem.Position, currentItem.Text, currentItem.Style);
        }
コード例 #4
0
        public override HealthMonitorDetails ParseHealthMonitor(string text, TextStorage storage)
        {
            if (text.EndsWith(TraceSourceString))
                text = text.Replace(TraceSourceString, string.Empty);

            return base.ParseHealthMonitor(text, storage);
        }
        public override HealthMonitorDetails ParseHealthMonitor(string text, TextStorage storage)
        {
            if (text.EndsWith(TraceSourceString))
            {
                text = text.Replace(TraceSourceString, string.Empty);
            }

            return(base.ParseHealthMonitor(text, storage));
        }
コード例 #6
0
        public override LogEntry ParseLine(string line, DateTime startDateTime, TextStorage storage)
        {
            if (ContainsStandardTracesource(line))
                line = line.Substring(0, line.Length - StandardTraceSource.Length);

            LogEntry logEntry = base.ParseLine(line, startDateTime, storage);
            if (logEntry != null)
                logEntry.LinesCount = logEntry.Text.GetLinesCount();
            
            return logEntry;
        }
コード例 #7
0
        NSUrl GetLinkAtPos(NSEvent theEvent)
        {
            var i = GetCharacterIndex(Window.ConvertRectToScreen(new CGRect(theEvent.LocationInWindow, CGSize.Empty)).Location);

            if (i >= 0)
            {
                NSRange r;
                var     attr = TextStorage.GetAttribute(NSStringAttributeKey.Link, (nint)i, out r) as NSUrl;
                if (attr != null && r.Length > 0)
                {
                    return(attr);
                }
            }
            return(null);
        }
コード例 #8
0
        public void SetHtmlString(string text)
        {
            NSDictionary dictionary;
            NSError      error;

            var atts = new NSAttributedStringDocumentAttributes {
                DocumentType   = NSDocumentType.HTML,
                StringEncoding = NSStringEncoding.UTF8
            };

            var htmlText = string.Concat("<font face=\"Helvetica\" style=\"font-size:10pt\"", text, "</font>");

            TextStorage.SetString(new NSAttributedString(NSData.FromString(htmlText), atts, out dictionary, out error));

            RemoveAllToolTips();
        }
コード例 #9
0
        /// <summary>
        /// Outdents the currently selected text.
        /// </summary>
        public void OutdentText()
        {
            // Grab range
            var range = Formatter.FindLineBoundries(TextStorage.Value, SelectedRange);
            var line  = TextStorage.Value.Substring((int)range.Location, (int)range.Length);

            // Decrease tab indent
            var output = DecreaseTabIndent(line);

            // reformat section
            TextStorage.BeginEditing();
            Replace(range, output);
            TextStorage.EndEditing();
            SelectedRange = new NSRange(range.Location, output.Length);
            Formatter.HighlightSyntaxRegion(TextStorage.Value, SelectedRange);
        }
コード例 #10
0
        public override LogEntry ParseLine(string line, DateTime startDateTime, TextStorage storage)
        {
            if (ContainsStandardTracesource(line))
            {
                line = line.Substring(0, line.Length - StandardTraceSource.Length);
            }

            LogEntry logEntry = base.ParseLine(line, startDateTime, storage);

            if (logEntry != null)
            {
                logEntry.LinesCount = logEntry.Text.GetLinesCount();
            }

            return(logEntry);
        }
コード例 #11
0
    public void ShowGoalInformation()
    {
        Cursor.visible = true;
        // Activate UI components
        tryAgainButton.gameObject.SetActive(true);
        goalText.gameObject.SetActive(true);
        medalArea.gameObject.SetActive(true);
        quitButton.gameObject.SetActive(true);
        // Get and set medal information
        var  info                = MedalStorage.GetLevelInfo(GameManager.currentLevel);
        var  goldMinimumTime     = info[2];
        var  silverMinimumTime   = info[1];
        var  bronzeMinimumTime   = info[0];
        var  time                = timer.ElapsedMilliseconds / 1000;
        bool showNextLevelButton = true;

        if (time > bronzeMinimumTime)  // No medal
        {
            receivedMedal       = 0;
            showNextLevelButton = false;
            medalArea.enabled   = false;
            goalText.text       = TextStorage.GetSlowText();
        }
        else if (time <= bronzeMinimumTime && time > silverMinimumTime)  // Bronze medal
        {
            receivedMedal     = 3;
            medalArea.texture = bronzeMedal;
            goalText.text     = TextStorage.GetBronzeText();
        }
        else if (time <= silverMinimumTime && time > goldMinimumTime) // Silver
        {
            receivedMedal     = 2;
            medalArea.texture = silverMedal;
            goalText.text     = TextStorage.GetSilverText();
        }
        else // Gold time
        {
            receivedMedal     = 1;
            medalArea.texture = goldMedal;
            goalText.text     = TextStorage.GetGoldText();
        }
        if (showNextLevelButton)
        {
            nextLevelButton.gameObject.SetActive(true);
        }
    }
コード例 #12
0
 public override void ResetCursorRects()
 {
     base.ResetCursorRects();
     // NSTextView sets the link cursors only in selectable mode
     // Do the same when Selectable == false
     if (!Selectable && TextStorage?.Length > 0)
     {
         TextStorage.EnumerateAttributes(new NSRange(0, TextStorage.Length), NSAttributedStringEnumeration.None, (NSDictionary attrs, NSRange range, ref bool stop) => {
             stop = false;
             if (attrs.ContainsKey(NSStringAttributeKey.Link))
             {
                 var rects = RectsForCharacterRange(range);
                 for (nuint i = 0; i < rects.Count; i++)
                 {
                     AddCursorRect(rects.GetItem <NSValue> (i).CGRectValue, NSCursor.PointingHandCursor);
                 }
             }
         });
     }
 }
コード例 #13
0
 protected override ParsingResult ParseSource(ILogSource source, LogReaderSettings settings, ParsingResult result = null)
 {
     if (source == null)
         throw new ArgumentNullException(nameof(source));
     
     TextStorage storage = new TextStorage();
     result = result ?? new ParsingResult();
     var log = (IEnumerable<string[]>)source;
     if (!(source is AzureLogSource))
         throw new ApplicationException("Non Azure log source was tried to be parsed by Azure log reader");
     
     foreach (var lines in log)
     {
         var logEntry = logParser.ParseLine(lines[0], new DateTime(long.Parse(lines[1])), storage);
         if (logEntry != null)
         {
             logEntry = AnalyzeLog(logEntry, storage);
             result.AddToGroupAll(logEntry);
         }
     }
     return result;
 }
コード例 #14
0
        /// <summary>
        /// Process any drag operations initialized by the user to this <see cref="AppKit.TextKit.Formatter.SourceTextView"/>.
        /// If one or more files have dragged in, the contents of those files will be copied into the document at the
        /// current cursor location.
        /// </summary>
        /// <returns><c>true</c>, if drag operation was performed, <c>false</c> otherwise.</returns>
        /// <param name="sender">The caller that initiated the drag operation.</param>
        /// <remarks>
        /// See Apple's drag and drop docs for more details (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html)
        /// </remarks>
        public override bool PerformDragOperation(NSDraggingInfo sender)
        {
            // Attempt to read filenames from pasteboard
            var plist = (NSArray)sender.DraggingPasteboard.GetPropertyListForType(NSPasteboard.NSFilenamesType);

            // Was a list of files returned from Finder?
            if (plist != null)
            {
                // Yes, process list
                for (nuint n = 0; n < plist.Count; ++n)
                {
                    // Get the current file
                    var path     = plist.GetItem <NSString> (n);
                    var url      = NSUrl.FromString(path);
                    var contents = File.ReadAllText(path);

                    // Insert contents at cursor
                    NSRange range = SelectedRange;
                    TextStorage.BeginEditing();
                    Replace(range, contents);
                    TextStorage.EndEditing();

                    // Expand range to fully encompass new content and
                    // reformat
                    range = new NSRange(range.Location, contents.Length);
                    range = Formatter.FindLineBoundries(TextStorage.Value, range);
                    Formatter.HighlightSyntaxRegion(TextStorage.Value, range);
                }

                // Inform caller of success
                return(true);
            }
            else
            {
                // No, allow base class to handle
                return(base.PerformDragOperation(sender));
            }
        }
コード例 #15
0
        /// <summary>
        /// Look for special keys being pressed and does specific processing based on
        /// the key.
        /// </summary>
        /// <param name="theEvent">The event.</param>
        public override void KeyDown(NSEvent theEvent)
        {
            NSRange range            = new NSRange(0, 0);
            string  line             = "";
            int     indentLevel      = 0;
            bool    consumeKeystroke = false;

            // Avoid processing if no Formatter has been attached
            if (Formatter == null)
            {
                return;
            }

            // Trap all errors
            try {
                // Get the code of current character
                var c        = theEvent.Characters [0];
                var charCode = (int)theEvent.Characters [0];

                // Preprocess based on character code
                switch (charCode)
                {
                case EnterKey:
                    // Get the tab indent level
                    range       = Formatter.FindLineBoundries(TextStorage.Value, SelectedRange);
                    line        = TextStorage.Value.Substring((int)range.Location, (int)range.Length);
                    indentLevel = CalculateIndentLevel(line);
                    break;

                case TabKey:
                    // Is a range selected?
                    if (SelectedRange.Length > 0)
                    {
                        // Increase tab indent over the entire selection
                        IndentText();
                        consumeKeystroke = true;
                    }
                    break;

                case ShiftTabKey:
                    // Is a range selected?
                    if (SelectedRange.Length > 0)
                    {
                        // Increase tab indent over the entire selection
                        OutdentText();
                        consumeKeystroke = true;
                    }
                    break;

                default:
                    // Are we completing closures
                    if (CompleteClosures)
                    {
                        if (WrapClosures && SelectedRange.Length > 0)
                        {
                            // Yes, see if we are starting a closure
                            foreach (LanguageClosure closure in Formatter.Language.Closures)
                            {
                                // Found?
                                if (closure.StartingCharacter == c)
                                {
                                    // Yes, get selected text
                                    var location = SelectedRange.Location;
                                    line = TextStorage.Value.Substring((int)SelectedRange.Location, (int)SelectedRange.Length);
                                    var output = "";
                                    output += closure.StartingCharacter;
                                    output += line;
                                    output += closure.EndingCharacter;
                                    TextStorage.BeginEditing();
                                    Replace(SelectedRange, output);
                                    TextStorage.EndEditing();
                                    if (SelectAfterWrap)
                                    {
                                        SelectedRange = new NSRange(location, output.Length);
                                    }
                                    consumeKeystroke = true;
                                    Formatter.HighlightSyntaxRegion(TextStorage.Value, SelectedRange);
                                }
                            }
                        }
                        else
                        {
                            // Yes, see if we are in a language defined closure
                            foreach (LanguageClosure closure in Formatter.Language.Closures)
                            {
                                // Found?
                                if (closure.StartingCharacter == c)
                                {
                                    // Is this a valid location for a completion?
                                    if (Formatter.TrailingCharacterIsWhitespaceOrTerminator(TextStorage.Value, SelectedRange))
                                    {
                                        // Yes, complete closure
                                        consumeKeystroke = true;
                                        var output = "";
                                        output += closure.StartingCharacter;
                                        output += closure.EndingCharacter;
                                        TextStorage.BeginEditing();
                                        InsertText(new NSString(output));
                                        TextStorage.EndEditing();
                                        SelectedRange = new NSRange(SelectedRange.Location - 1, 0);
                                    }
                                }
                            }
                        }
                    }
                    break;
                }

                // Call base to handle event
                if (!consumeKeystroke)
                {
                    base.KeyDown(theEvent);
                }

                // Post process based on character code
                switch (charCode)
                {
                case EnterKey:
                    // Tab indent the new line to the same level
                    if (indentLevel > 0)
                    {
                        var indent = TabIndent(indentLevel);
                        TextStorage.BeginEditing();
                        InsertText(new NSString(indent));
                        TextStorage.EndEditing();
                    }
                    break;
                }
            } catch {
                // Call base to process on any error
                base.KeyDown(theEvent);
            }

            //Console.WriteLine ("Key: {0}", (int)theEvent.Characters[0]);
        }
コード例 #16
0
 public ButtonEdit()
 {
     _storage = new TextStorage(this);
 }
コード例 #17
0
 private void Start()
 {
     _textStorage    = GetComponent <TextStorage>();
     titeleText.text = "Привет";
     questText.text  = "Жми N";
 }
コード例 #18
0
 public GoalRepository(TextStorage storage)
 {
     _storage = storage;
 }