63
65
Gtk.TextIter select_start, select_end;
65
67
if (GetSelectionBounds (out select_start, out select_end)) {
68
// Ignore the bullet character
69
if (FindDepthTag(ref select_start) != null)
70
select_start.LineOffset = 2;
66
72
if (select_start.BeginsTag (tag) || select_start.HasTag (tag))
67
73
RemoveTag (tag, select_start, select_end);
112
public void OnTagApplied (object o, Gtk.TagAppliedArgs args)
114
if (!(args.Tag is DepthNoteTag)) {
115
// Remove the tag from any bullets in the selection
116
Undoer.FreezeUndo ();
118
for (int i = args.StartChar.Line; i <= args.EndChar.Line; i++) {
119
iter = GetIterAtLine(i);
121
if (FindDepthTag (ref iter) != null) {
122
Gtk.TextIter next = iter;
123
next.ForwardChars (2);
124
RemoveTag (args.Tag, iter, next);
129
// Remove any existing tags when a depth tag is applied
130
Undoer.FreezeUndo ();
131
foreach (Gtk.TextTag tag in args.StartChar.Tags) {
132
if (!(tag is DepthNoteTag)) {
133
RemoveTag (tag, args.StartChar, args.EndChar);
106
140
public bool IsActiveTag (string tag_name)
108
142
Gtk.TextTag tag = TagTable.Lookup (tag_name);
109
143
Gtk.TextIter iter, select_end;
111
if (GetSelectionBounds (out iter, out select_end))
145
if (GetSelectionBounds (out iter, out select_end)) {
146
// Ignore the bullet character and look at the
147
// first character of the list item
148
if (FindDepthTag(ref iter) != null)
149
iter.ForwardChars (2);
112
150
return iter.BeginsTag (tag) || iter.HasTag (tag);
114
152
return active_tags.Contains (tag);
117
156
// Returns true if the cursor is inside of a bulleted list
171
// Returns true if the cursor is at a position that can
172
// be made into a bulleted list
173
public bool CanMakeBulletedList ()
175
Gtk.TextMark insert_mark = InsertMark;
176
Gtk.TextIter iter = GetIterAtMark (insert_mark);
132
184
// Apply active_tags to inserted text
133
185
void TextInsertedEvent (object sender, Gtk.InsertTextArgs args)
596
651
public void IncreaseCursorDepth ()
598
Gtk.TextMark insert_mark = InsertMark;
599
Gtk.TextIter insert_iter = GetIterAtMark (insert_mark);
601
insert_iter.LineOffset = 0;
603
IncreaseDepth (ref insert_iter);
653
ChangeCursorDepth (true);
606
656
public void DecreaseCursorDepth ()
608
Gtk.TextMark insert_mark = InsertMark;
609
Gtk.TextIter insert_iter = GetIterAtMark (insert_mark);
611
DecreaseDepth (ref insert_iter);
658
ChangeCursorDepth (false);
661
void ChangeCursorDepth(bool increase)
666
GetSelectionBounds (out start, out end);
668
Gtk.TextIter curr_line;
670
int start_line = start.Line;
671
int end_line = end.Line;
673
for (int i = start_line; i <= end_line; i++) {
674
curr_line = GetIterAtLine(i);
676
IncreaseDepth (ref curr_line);
678
DecreaseDepth (ref curr_line);
614
682
public void InsertBullet (ref Gtk.TextIter iter, int depth)
930
1004
bool end_of_depth_line = line_has_depth && next_iter.EndsLine ();
932
1006
bool next_line_has_depth = false;
933
if (iter.Line < buffer.LineCount) {
1007
if (iter.Line < buffer.LineCount - 1) {
934
1008
Gtk.TextIter next_line = buffer.GetIterAtLine(iter.Line+1);
935
1009
next_line_has_depth =
936
1010
((NoteBuffer)buffer).FindDepthTag(ref next_line) != null;