Beispiel #1
0
        public void Set(ScriptWindow parent, string tag, string localized)
        {
            LocalizedTag = tag;
            var lines = localized.Split(new[] { "\\n" }, StringSplitOptions.None);

            ParentWindow = parent;

            localTextEdit.Document.TextContent = string.Join("\n", lines);
            var c = Color.FromArgb(255, 42, 54, 40);

            localTextEdit.Document.ReadOnly = false;

            var d = localTextEdit.Document.HighlightingStrategy as DefaultHighlightingStrategy;
            {
                var s  = Color.FromArgb(255, 73, 92, 70);
                var cl = Color.FromArgb(255, 43, 62, 40);

                d.environmentColors["Default"].BackgroundColor  = c;
                d.environmentColors["FoldLine"].BackgroundColor = c;
                d.environmentColors["VRuler"].BackgroundColor   = c;

                d.environmentColors["Selection"].BackgroundColor = s;
                d.environmentColors["CaretLine"].BackgroundColor = cl;
                //  d.environmentColors["VRuler"].BackgroundColor = c;
                d.DigitColor.BackgroundColor       = c;
                d.DefaultTextColor.BackgroundColor = c;

                backgroundColor = c;


                foreach (var lineSegment in localTextEdit.Document.LineSegmentCollection)
                {
                    foreach (var lineSegmentWord in lineSegment.Words)
                    {
                        if (lineSegmentWord.SyntaxColor != null)
                        {
                            lineSegmentWord.SyntaxColor = new HighlightColor(lineSegmentWord.SyntaxColor.Color,
                                                                             lineSegmentWord.SyntaxColor.BackgroundColor, lineSegmentWord.SyntaxColor.Bold,
                                                                             lineSegmentWord.SyntaxColor.Italic);
                            lineSegmentWord.SyntaxColor.BackgroundColor = c;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void DoComplete()
        {
            Control.ActiveTextAreaControl.TextArea.Focus();
            var ls   = Control.Document.GetLineSegment(Control.ActiveTextAreaControl.Caret.Line);
            var t    = suggestionListbox.Items[suggestionListbox.SelectedIndices[0]].Text;
            var tabs = TabSpacing;

            var needBraces = false; //CoreIntellisenseHandler.Instance.GetNeedBraces(Inside, t);

            if (!autoCompletePostEquals)
            {
                t += " = ";
            }
            else
            {
                StartText = StartText.TrimEnd(' ');
                if (t == "{ }")
                {
                    t          = "";
                    t         += " {\n" + tabs + "\t\n" + tabs + "}";
                    needBraces = true;
                }
                else
                {
                    t = " " + t;
                }
            }


            Control.Document.Replace(ls.Offset, ls.Length,
                                     StartText + t);

            if (!needBraces)
            {
                Control.ActiveTextAreaControl.Caret.Column = (StartText + t).Length;
            }
            else
            {
                Control.ActiveTextAreaControl.Caret.Line++;
                Control.ActiveTextAreaControl.Caret.Column = tabs.Length + 1;
            }

            ScriptWindow.UpdateDatabase();
        }
Beispiel #3
0
 public BasicFind(ScriptWindow window)
 {
     InitializeComponent();
     this.Window = window;
 }
Beispiel #4
0
        public bool FillIntellisense(ScriptWindow sw, TextEditorControl control, string lineSegment, int caretColumn,
                                     ScriptObject inside)
        {
            ScriptWindow = sw;
            Control      = control;
            var before = lineSegment.Substring(0, caretColumn);
            var after  = lineSegment.Substring(caretColumn);

            if (after.Trim().Length > 0 && (after[0] != ' ' || after[0] != '\t'))
            {
                return(false);
            }

            Size = new Size(600, 400);
            var startOfLastword = before.IndexOf(before.Trim());

            TabSpacing = before.Substring(0, startOfLastword);
            if (before.Trim().Length == 0)
            {
                TabSpacing = before;
            }
            var endOfLastWord = before.IndexOf(before.Trim()) + before.Trim().Length;

            Inside = inside;
            var beforeOriginal = before;

            before = before.Trim();
            var choices = new List <string>();

            if (before.Length == 0 && !Force)
            {
                return(false);
            }

            if (before.Contains("=") || before.Contains("<=") || before.Contains(">=") || before.Contains("!=") ||
                before.Contains("=="))
            {
                beforeOriginal = beforeOriginal.Replace("==", "*");
                beforeOriginal = beforeOriginal.Replace("<=", "*");
                beforeOriginal = beforeOriginal.Replace(">=", "*");
                beforeOriginal = beforeOriginal.Replace("!=", "*");
                beforeOriginal = beforeOriginal.Replace("==", "*");
                beforeOriginal = beforeOriginal.Replace("=", "*");
                var afterOpindex = beforeOriginal.IndexOf("*") + 1;
                before = before.Replace("==", "*");
                before = before.Replace("<=", "*");
                before = before.Replace(">=", "*");
                before = before.Replace("!=", "*");
                before = before.Replace("==", "*");
                before = before.Replace("=", "*");
                var beforeReplaced = before;
                var sofar          = before.Substring(before.LastIndexOf("*") + 1).Trim();
                before = before.Substring(0, before.LastIndexOf("*")).Trim();
                var dif = beforeOriginal.Length - beforeOriginal.TrimEnd(' ').Length;

                if (!beforeReplaced.Trim().EndsWith("*"))
                {
                    dif = 1;
                }

                if (dif >= 1)
                {
                    // find appropriate choices for type before =
                    choices = CoreIntellisenseHandler.Instance.GetValidTokensEqual(inside, before, sofar);

                    var index = lineSegment.IndexOf(before);

                    StartText = lineSegment.Substring(0, afterOpindex);
                    autoCompletePostEquals = true;
                }
            }
            else
            {
                if (endOfLastWord < caretColumn && before.Length > 0)
                {
                    return(false);
                }

                choices = CoreIntellisenseHandler.Instance.GetValidTokens(inside, before);

                var index = lineSegment.IndexOf(before);

                StartText = lineSegment.Substring(0, index);
                if (before.Length == 0)
                {
                    StartText = lineSegment.Substring(0, caretColumn);
                }

                autoCompletePostEquals = false;
            }

            suggestionListbox.Items.Clear();
            if (choices.Count == 0)
            {
                return(false);
            }

            suggestionListbox.SuspendEvents(true);

            foreach (var choice in choices)
            {
                var l = new DarkListItem(choice);
                suggestionListbox.Items.Add(l);
            }

            suggestionListbox.SuspendEvents(false);

            suggestionListbox.SelectItem(0);
            Size = new Size(Size.Width,
                            Math.Min(choices.Count * suggestionListbox.ItemHeight + 5, 10 * suggestionListbox.ItemHeight));

            return(true);
        }
Beispiel #5
0
 public void MoveToStartOfDocumentList(ScriptWindow scriptWindow)
 {
     openScriptWindows.Remove(scriptWindow);
     openScriptWindows.Insert(0, scriptWindow);
 }
Beispiel #6
0
 public void Add(ScriptWindow window)
 {
     openScriptWindows.Add(window);
 }
Beispiel #7
0
 public bool Contains(ScriptWindow window)
 {
     return(openScriptWindows.Contains(window));
 }
Beispiel #8
0
 public void ActivateWindow(ScriptWindow scriptWindow)
 {
     DockPanel.ActiveContent = scriptWindow;
 }