Esempio n. 1
0
        public bool IndentSelection(bool unindent, bool requireLineSelection)
        {
            TextIter begin, end;
            bool     hasSelection = buf.GetSelectionBounds(out begin, out end);

            if (!hasSelection)
            {
                if (requireLineSelection)
                {
                    return(false);
                }
                else
                {
                    begin = end = buf.GetIterAtMark(buf.InsertMark);
                }
            }

            int y0 = begin.Line, y1 = end.Line;

            if (requireLineSelection && y0 == y1)
            {
                return(false);
            }

            // If last line isn't selected, it's illogical to indent it.
            if (end.StartsLine() && hasSelection && y0 != y1)
            {
                y1--;
            }

            using (AtomicUndo a = new AtomicUndo(buf)) {
                if (unindent)
                {
                    UnIndentLines(y0, y1);
                }
                else
                {
                    IndentLines(y0, y1);
                }
                if (hasSelection)
                {
                    SelectLines(y0, y1);
                }
            }

            return(true);
        }
Esempio n. 2
0
        internal void DeleteLine()
        {
            TextIter start = buf.GetIterAtMark(buf.InsertMark);
            TextIter end   = start;

            if (!end.EndsLine())
            {
                // Delete up to, but not including, the end-of-line marker
                end.ForwardToLineEnd();
            }
            else
            {
                // Delete the end-of-line marker
                end.Offset++;
            }

            using (AtomicUndo a = new AtomicUndo(buf))
                buf.Delete(ref start, ref end);
        }
 public void StartAtomicUndo()
 {
     atomic_undo = new AtomicUndo(this);
 }
		public void StartAtomicUndo ()
		{
			atomic_undo = new AtomicUndo (this);
		}
		public bool IndentSelection (bool unindent, bool requireLineSelection)
		{
			TextIter begin, end;
			bool hasSelection = buf.GetSelectionBounds (out begin, out end);
			if (!hasSelection) {
				if (requireLineSelection)
					return false;
				else
					begin = end = buf.GetIterAtMark (buf.InsertMark);
			}
			
			int y0 = begin.Line, y1 = end.Line;
			
			if (requireLineSelection && y0 == y1)
				return false;

			// If last line isn't selected, it's illogical to indent it.
			if (end.StartsLine() && hasSelection && y0 != y1)
				y1--;

			using (AtomicUndo a = new AtomicUndo (buf)) {
				if (unindent)
					UnIndentLines (y0, y1);
				else
					IndentLines (y0, y1);
				if (hasSelection)
					SelectLines (y0, y1);
			}
			
			return true;
		}
		internal void DeleteLine ()
		{
			TextIter start = buf.GetIterAtMark (buf.InsertMark);
			TextIter end = start;
			
			if (!end.EndsLine ()) {
				// Delete up to, but not including, the end-of-line marker
				end.ForwardToLineEnd ();
			} else {
				// Delete the end-of-line marker
				end.Offset++;
			}
			
			using (AtomicUndo a = new AtomicUndo (buf)) 
				buf.Delete (ref start, ref end);
		}
 void DeleteLine()
 {
     //remove the current line
     TextIter iter = buf.GetIterAtMark (buf.InsertMark);
     iter.LineOffset = 0;
     TextIter end_iter = buf.GetIterAtLine (iter.Line);
     end_iter.LineOffset = end_iter.CharsInLine;
     using (AtomicUndo a = new AtomicUndo (buf))
         buf.Delete (ref iter, ref end_iter);
 }
        public bool UnIndentSelection()
        {
            TextIter begin, end;
            if (! buf.GetSelectionBounds (out begin, out end))
                return false;

            int y0 = begin.Line, y1 = end.Line;

            // If last line isn't selected, it's illogical to indent it.
            if (end.StartsLine())
                y1--;

            if (y0 == y1)
                return false;

            using (AtomicUndo a = new AtomicUndo (buf)) {
                UnIndentLines (y0, y1);
                SelectLines (y0, y1);
            }

            return true;
        }