Beispiel #1
0
        public override void Merge(EditAction action)
        {
            EraseAction erase = (EraseAction)action;

            if (start == erase.start)
            {
                end     += erase.end - erase.start;
                chop.End = erase.chop.End;

                // Delete the marks, leave the text
                erase.chop.Destroy();
            }
            else
            {
                start = erase.start;

                Gtk.TextIter chop_start = chop.Start;
                chop.Buffer.InsertRange(ref chop_start,
                                        erase.chop.Start,
                                        erase.chop.End);

                // Delete the marks and text
                erase.Destroy();
            }
        }
Beispiel #2
0
        public override bool CanMerge(EditAction action)
        {
            EraseAction erase = action as EraseAction;

            if (erase == null)
            {
                return(false);
            }

            // Don't group separate text cuts
            if (is_cut || erase.is_cut)
            {
                return(false);
            }

            // Must meet eachother
            if (start != (is_forward ? erase.start : erase.end))
            {
                return(false);
            }

            // Don't group deletes with backspaces
            if (is_forward != erase.is_forward)
            {
                return(false);
            }

            // Group if something other than text was deleted
            // (e.g. an email image)
            if (chop.Text.Length == 0 || erase.chop.Text.Length == 0)
            {
                return(true);
            }

            // Don't group more than one line (inclusive)
            if (chop.Text[0] == '\n')
            {
                return(false);
            }

            // Don't group more than one word (exclusive)
            if (erase.chop.Text[0] == ' ' || erase.chop.Text[0] == '\t')
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        void OnDeleteRange(object sender, Gtk.DeleteRangeArgs args)
        {
            if (frozen_cnt == 0)
            {
                EraseAction action = new EraseAction(args.Start,
                                                     args.End,
                                                     chop_buffer);

                /*
                 * Delete works a lot like insert here, except
                 * there are two positions in the buffer that
                 * may need to have their tags removed.
                 */
                frozen_cnt++;
                action.Split(args.Start, buffer);
                action.Split(args.End, buffer);
                frozen_cnt--;

                AddUndoAction(action);
            }
        }
Beispiel #4
0
		void OnDeleteRange (object sender, Gtk.DeleteRangeArgs args)
		{
			if (frozen_cnt == 0) {
				EraseAction action = new EraseAction (args.Start,
				                                      args.End,
				                                      chop_buffer);
				/*
				 * Delete works a lot like insert here, except
				 * there are two positions in the buffer that
				 * may need to have their tags removed.
				 */
				frozen_cnt++;
				action.Split (args.Start, buffer);
				action.Split (args.End, buffer);
				frozen_cnt--;

				AddUndoAction (action);
			}
		}