void ApplyCJKToBlock(Gtk.TextIter start, Gtk.TextIter end)
        {
            NoteBuffer.GetBlockExtents (ref start,
                    ref end,
                    512 /* XXX */,
                    cjk_tag);

            Buffer.RemoveTag (cjk_tag, start, end);

            MatchCJK m = new MatchCJK (start.GetText (end));
            foreach (MatchCJK.CJKGroup g in m) {
                Gtk.TextIter start_cpy = start;
                start_cpy.ForwardChars (g.Start);

                end = start;
                end.ForwardChars (g.End);

                Buffer.ApplyTag (cjk_tag, start_cpy, end);
            }
        }
        void ApplyEALToBlock(Gtk.TextIter start, Gtk.TextIter end)
        {
            AddLanguageTag ();

            NoteBuffer.GetBlockExtents (ref start,
                    ref end,
                    512 /* XXX */,
                    eal_tag);
            Buffer.RemoveTag (eal_tag, start, end);

            MatchEAL m = new MatchEAL (start.GetText (end));
            foreach (MatchEAL.EALGroup g in m) {
                Gtk.TextIter start_cpy = start;
                start_cpy.ForwardChars (g.Start);

                end = start;
                end.ForwardChars (g.End);

                Buffer.ApplyTag (eal_tag, start_cpy, end);
            }
        }
示例#3
0
		public void IncreaseDepth (ref Gtk.TextIter start)
		{
			if (!CanMakeBulletedList())
				return;

			Gtk.TextIter end;

			start = GetIterAtLineOffset (start.Line, 0);

			Gtk.TextIter line_end = GetIterAtLine (start.Line);
			line_end.ForwardToLineEnd ();

			end = start;
			end.ForwardChars (2);

			DepthNoteTag curr_depth = FindDepthTag (start);

			Undoer.FreezeUndo ();
			if (curr_depth == null) {
				// Insert a brand new bullet
				Gtk.TextIter next = start;
				next.ForwardSentenceEnd ();
				next.BackwardSentenceStart ();

				// Insert the bullet using the same direction
				// as the text on the line
				Pango.Direction direction = Pango.Direction.Ltr;
				if (next.Char.Length > 0 && next.Line == start.Line)
					direction = Pango.Global.UnicharDirection (next.Char[0]);

				InsertBullet (ref start, 0, direction);
			} else {
				// Remove the previous indent
				Delete (ref start, ref end);

				// Insert the indent at the new depth
				int nextDepth = curr_depth.Depth + 1;
				InsertBullet (ref start, nextDepth, curr_depth.Direction);
			}
			Undoer.ThawUndo ();

			ChangeTextDepth (this, new ChangeDepthEventArgs (start.Line, true));
		}
示例#4
0
		void ApplyWikiwordToBlock (Gtk.TextIter start, Gtk.TextIter end)
		{
			NoteBuffer.GetBlockExtents (ref start,
			                            ref end,
			                            80 /* max wiki name */,
			                            broken_link_tag);

			Buffer.RemoveTag (broken_link_tag, start, end);

			for (Match match = regex.Match (start.GetText (end));
			                match.Success;
			                match = match.NextMatch ()) {
				System.Text.RegularExpressions.Group group = match.Groups [1];

				Gtk.TextIter start_cpy = start;
				start_cpy.ForwardChars (group.Index);

				end = start_cpy;
				end.ForwardChars (group.Length);

				if (Note.TagTable.HasLinkTag (start_cpy))
					break;

				Logger.Debug ("Highlighting wikiword: '{0}' at offset {1}",
							group,
							group.Index);

				if (Manager.Find (group.ToString ()) == null) {
					Buffer.ApplyTag (broken_link_tag, start_cpy, end);
				}
			}
		}
示例#5
0
		void ApplyUrlToBlock (Gtk.TextIter start, Gtk.TextIter end)
		{
			NoteBuffer.GetBlockExtents (ref start,
			                            ref end,
			                            256 /* max url length */,
			                            Note.TagTable.UrlTag);

			Buffer.RemoveTag (Note.TagTable.UrlTag, start, end);

			for (Match match = regex.Match (start.GetSlice (end));
			                match.Success;
			                match = match.NextMatch ()) {
				System.Text.RegularExpressions.Group group = match.Groups [1];

				/*
				Logger.Log ("Highlighting url: '{0}' at offset {1}",
				     group,
				     group.Index);
				*/

				Gtk.TextIter start_cpy = start;
				start_cpy.ForwardChars (group.Index);

				end = start_cpy;
				end.ForwardChars (group.Length);

				Buffer.ApplyTag (Note.TagTable.UrlTag, start_cpy, end);
			}
		}