Exemplo n.º 1
0
        public void Caret_PositionChanged(EditorControl editor)
        {
            if (tmpEditor != null && tmpEditor != editor)
            {
                ClearMarkers(tmpEditor);
            }

            if (mouseEndPosition != null)
            {
                TextLocation tl = editor.Document.OffsetToPosition(mouseEndPosition.Offset);

                if ((tl.Line != editor.Caret.Position.Line) || (editor.Caret.Position.Column >= tl.Column))
                {
                    removeMouseEndPosition(editor);
                }
            }

            if (processTemplate)
            {
                if (CurrentTemplate != null)
                {
                    ExpressionMarker expression = CurrentTemplate.GetExpressionMarkerAtPos(editor.Caret.Offset, editor);
                    if (expression != null)
                    {
                        expression.ReplaceExpressionMarker(editor);
                    }
                    else
                    {
                        ClearMarkers(editor);
                        CurrentTemplate = null;
                        processTemplate = false;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public List <CopyMarker> GetChildsOfParent(string varName)
        {
            ExpressionMarker  parent         = null;
            List <CopyMarker> copyMarkerList = new List <CopyMarker>();

            foreach (var item in list)
            {
                if (item.VariableName == varName)
                {
                    parent = item;
                    continue;
                }
                if (parent != null)
                {
                    if (item is CopyMarker)
                    {
                        if (parent == (item as CopyMarker).Parent)
                        {
                            copyMarkerList.Add((item as CopyMarker));
                        }
                    }
                }
            }
            return(copyMarkerList);
        }
Exemplo n.º 3
0
 public CopyMarker(int beginOffset, int length, ExpressionMarker parent)
 {
     markerColor     = Color.Black;
     base.MarkerType = TextMarkerType.CopyMarker;
     Expression      = new QuickletMarker(beginOffset, length, MarkerType, markerColor);
     Begin           = new QuickletMarker(beginOffset - 1, 1, TextMarkerType.Invisible, System.Drawing.Color.Aqua);
     End             = new QuickletMarker(beginOffset + length, 1, TextMarkerType.Invisible, System.Drawing.Color.Aqua);
     VariableName    = "";
     Parent          = parent;
 }
Exemplo n.º 4
0
        public bool SwitchBetweenExpressions(EditorControl editor)
        {
            ExpressionMarker expression = GetExpressionMarkerAtPos(editor.Caret.Offset, editor);

            if (expression != null)
            {
                if (!(list.Count() == 1))
                {
                    int index = list.IndexOf(expression);
                    if (index < list.Count())
                    {
                        if (list[index] == list.Last())
                        {
                            SelectExpression(0, editor);
                            return(true);
                        }
                        else
                        {
                            if (list[index + 1] is CopyMarker)
                            {
                                for (int i = index + 1; i < list.Count; i++)
                                {
                                    if (list[i] == list.Last())
                                    {
                                        if (list[i] is CopyMarker)
                                        {
                                            SelectExpression(0, editor);
                                            return(true);
                                        }
                                    }
                                    if (!(list[i] is CopyMarker))
                                    {
                                        SelectExpression(i, editor);
                                        return(true);
                                    }
                                }
                            }
                            SelectExpression(index + 1, editor);
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 5
0
        private void GenerateExpressions(string formattedTemplate, int shortcutBeginOffset)
        {
            cleanTemplate = formattedTemplate;
            list.Clear();
            int pos = 0;

            for (int i = 0; i < variablesInTemplate + 1; i++)
            {
                int begin = cleanTemplate.IndexOf("$", pos);
                int end   = cleanTemplate.IndexOf("$", begin + 1);
                end += 1;

                string varName = cleanTemplate.Substring(begin, end - begin);
                if (varName == "$end$")
                {
                    EndMarker     = new QuickletMarker(begin + shortcutBeginOffset, 1, TextMarkerType.QuickMark, Color.Red);
                    cleanTemplate = cleanTemplate.Remove(begin, "$end$".Length);
                }

                else
                {
                    Variable var = getVariableByName(varName);
                    if (var.Name != "")
                    {
                        cleanTemplate = cleanTemplate.Remove(begin, var.Name.Length);
                        cleanTemplate = cleanTemplate.Insert(begin, var.Value);

                        pos = begin + var.Value.Length;

                        ExpressionMarker parent = getParentMarker(var.Name);
                        if (parent == null)
                        {
                            list.Add(new ExpressionMarker(begin + shortcutBeginOffset, var.Value.Length, var.Name));
                        }
                        else
                        {
                            list.Add(new CopyMarker(begin + shortcutBeginOffset, var.Value.Length, parent));
                        }
                    }
                }
            }
        }