1/* 2* Copyright (c) 2020 (https://github.com/phase1geo/Outliner) 3* 4* This program is free software; you can redistribute it and/or 5* modify it under the terms of the GNU General Public 6* License as published by the Free Software Foundation; either 7* version 2 of the License, or (at your option) any later version. 8* 9* This program is distributed in the hope that it will be useful, 10* but WITHOUT ANY WARRANTY; without even the implied warranty of 11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12* General Public License for more details. 13* 14* You should have received a copy of the GNU General Public 15* License along with this program; if not, write to the 16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17* Boston, MA 02110-1301 USA 18* 19* Authored by: Trevor Williams <phase1geo@gmail.com> 20*/ 21 22public class UndoTextTagRemove : UndoTextItem { 23 24 public int start { private set; get; } 25 public int end { private set; get; } 26 public FormatTag tag { private set; get; } 27 public string? extra { private set; get; } 28 public bool parsed { private set; get; } 29 30 /* Default constructor */ 31 public UndoTextTagRemove( int start, int end, FormatTag tag, string? extra, bool parsed, int cursor ) { 32 base( _( "format tag remove" ), UndoTextOp.TAGDEL, cursor, cursor ); 33 this.start = start; 34 this.end = end; 35 this.tag = tag; 36 this.extra = extra; 37 this.parsed = parsed; 38 } 39 40 /* Causes the stored item to be put into the before state */ 41 public override void undo_text( DrawArea da, CanvasText ct ) { 42 ct.text.add_tag( tag, start, end, parsed, extra ); 43 ct.set_cursor_only( start_cursor ); 44 da.queue_draw(); 45 } 46 47 /* Causes the stored item to be put into the after state */ 48 public override void redo_text( DrawArea da, CanvasText ct ) { 49 ct.text.remove_tag( tag, start, end ); 50 ct.set_cursor_only( end_cursor ); 51 da.queue_draw(); 52 } 53 54 /* Merges the given item with the current one */ 55 public override bool merge( CanvasText ct, UndoTextItem item ) { 56 return( false ); 57 } 58 59} 60