public override bool InsertAction(EditViewControl textArea, char ch)
        {
            ClassFinder context = new ClassFinder(textArea.FileName,
                                                  textArea.Caret.Position.Y + 1, textArea.Caret.Position.X + 1);
            //int caretPosition = textArea.Caret.Offset;
            //LineSegment line = textArea.Document.GetLineSegment(textArea.Caret.Line);
            //string lineText = textArea.Document.GetText(line.Offset, caretPosition - line.Offset);
            string lineText = textArea.Caret.CurrentRow.Text;

            foreach (char c in lineText)
            {
                if (!char.IsWhiteSpace(c) && !char.IsLetterOrDigit(c))
                {
                    return(base.InsertAction(textArea, ch));
                }
            }
            string indentation = lineText.Substring(0, lineText.Length - lineText.TrimStart().Length);

            CodeGenerator codeGen = Parser.ProjectParser.CurrentProjectContent.Language.CodeGenerator;

            string text = codeGen.GenerateCode(codeGen.GetOverridingMethod(member, context), indentation);

            text = text.TrimEnd();             // remove newline from end
            //TODO:Rajneesh
            TextRange tr = textArea.Document.GetRangeFromText(lineText, 0, textArea.Caret.Position.Y);

            tr = textArea.Document.ReplaceRange(tr, text, true);

            textArea.Caret.SetPos(new TextPoint(tr.LastColumn, tr.LastRow));
            textArea.ScrollIntoView();
            return(true);
        }
Ejemplo n.º 2
0
 public void CaretMoved(bool Select)
 {
     Control.ScrollIntoView();
     if (!Select)
     {
         Control.Selection.ClearSelection();
     }
     else
     {
         Control.Selection.MakeSelection();
     }
 }