Ejemplo n.º 1
0
 /// <summary>
 ///     Common logic behind the push method.
 ///     Each state can override this method and implement its own logic.
 /// </summary>
 /// <param name="ch">
 ///     The current character that's being pushed.
 /// </param>
 public virtual void Push(char ch)
 {
     // replace ThisLineIndent with NextLineIndent if the newLineChar is pushed
     if (ch == Engine.newLineChar)
     {
         var delta = Engine.textEditorOptions.ContinuationIndent;
         while (NextLineIndent.CurIndent - ThisLineIndent.CurIndent > delta &&
                NextLineIndent.PopIf(IndentType.Continuation))
         {
             ;
         }
         ThisLineIndent = NextLineIndent.Clone();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Actions performed when this state exits.
        /// </summary>
        public virtual void OnExit()
        {
            if (Parent != null)
            {
                // if a state exits on the newline character, it has to push
                // it back to its parent (and so on recursively if the parent
                // state also exits). Otherwise, the parent state wouldn't
                // know that the engine isn't on the same line anymore.
                if (Engine.currentChar == Engine.newLineChar)
                {
                    Parent.Push(Engine.newLineChar);
                }

                // when a state exits the engine stays on the same line and this
                // state has to override the Parent.ThisLineIndent.
                Parent.ThisLineIndent = ThisLineIndent.Clone();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Initializes the state:
 ///       - sets the default indentation levels.
 /// </summary>
 /// <remarks>
 ///     Each state can override this method if it needs a different
 ///     logic for setting up the default indentations.
 /// </remarks>
 public virtual void InitializeState()
 {
     ThisLineIndent = new Indent(Engine.textEditorOptions);
     NextLineIndent = ThisLineIndent.Clone();
 }