예제 #1
0
        void OnInsertText(object sender, Gtk.InsertTextArgs args)
        {
            Update();

            Gtk.TextIter end = args.Pos;
            end.ForwardToLineEnd();

            // Avoid lingering note-title after a multi-line insert...
            Buffer.RemoveTag(title_tag, TitleEnd, end);

            //In the case of large copy and paste operations, show the end of the block
            this.Window.Editor.ScrollMarkOnscreen(this.Buffer.InsertMark);
        }
예제 #2
0
        void OnInsertText(object sender, Gtk.InsertTextArgs args)
        {
            Gtk.TextIter start = args.Pos;
            start.BackwardChars(args.Length);

            Gtk.TextIter end = args.Pos;

            NoteBuffer.GetBlockExtents(ref start,
                                       ref end,
                                       Manager.TitleTrie.MaxLength,
                                       Note.TagTable.LinkTag);

            UnhighlightInBlock(start, end);
            HighlightInBlock(start, end);
        }
예제 #3
0
        void HandleInsertText(object o, Gtk.InsertTextArgs args)
        {
            // when text is inserted, apply insertion formatting
            var buffer = Control.Buffer;

#if GTK3
            var start = buffer.GetIterAtOffset(args.Pos.Offset - args.NewTextLength);
#elif GTK2
            var start = buffer.GetIterAtOffset(args.Pos.Offset - args.Length);
#endif
            foreach (var tag in removeTags)
            {
                buffer.RemoveTag(tag, start, args.Pos);
            }
            foreach (var tag in insertTags)
            {
                buffer.ApplyTag(tag, start, args.Pos);
            }
            keepTags = true;
        }
예제 #4
0
        void OnInsertText(object sender, Gtk.InsertTextArgs args)
        {
            if (frozen_cnt == 0)
            {
                InsertAction action = new InsertAction(args.Pos,
                                                       args.Text,
                                                       args.Text.Length,
                                                       chop_buffer);

                /*
                 * If this insert occurs in the middle of any
                 * non-splittable tags, remove them first and
                 * add them to the InsertAction.
                 */
                frozen_cnt++;
                action.Split(args.Pos, buffer);
                frozen_cnt--;

                AddUndoAction(action);
            }
        }
예제 #5
0
        void OnInsertText(object sender, Gtk.InsertTextArgs args)
        {
            Gtk.TextIter start = args.Pos;
//Logger.Debug ("TaskNoteAddin.OnInsertText:\n" +
//    "\tLength: {0}\n" +
//    "\tText: {1}\n" +
//    "\tLine: {2}",
//    args.Length,
//    args.Text,
//    args.Pos.Line);

            if (args.Length == 1 && args.Text == "\n")
            {
                Gtk.TextIter curr_line = args.Pos;
                TaskTag      task_tag  = GetTaskTagFromLineIter(ref curr_line);

                Gtk.TextIter prev_line = args.Pos;
                prev_line.BackwardLine();
                /*TaskTag*/
                task_tag = GetTaskTagFromLineIter(ref prev_line);
                if (task_tag != null)
                {
                    // If the user just entered a newline and the previous
                    // line was a task, do some special processing...but
                    // we have to do it on idle since there are other
                    // Buffer.InsertText handlers that we'll screw up if
                    // we modify anything here.
                    args.RetVal = ProcessNewline();
                }
                else
                {
                    // Check to see if the previous line is a todo: line
                    while (prev_line.StartsLine() == false)
                    {
                        prev_line.BackwardChar();
                    }

                    Gtk.TextIter prev_line_end = prev_line;
                    while (prev_line_end.EndsLine() == false)
                    {
                        prev_line_end.ForwardChar();
                    }

                    string prev_line_text = prev_line.GetText(prev_line_end);

                    Match match = regex.Match(prev_line_text);
                    if (match.Success && last_removed_tag != null)
                    {
                        TaskManager task_mgr = TasksApplicationAddin.DefaultTaskManager;
                        Task        task;

                        task = task_mgr.FindByUri(last_removed_tag.Uri);
                        if (task != null)
                        {
                            // Update the task's summary and make sure that
                            // the previous line is appropriately tagged.
                            string summary = GetTaskSummaryFromLine(prev_line_text);
                            task.Summary = summary;
                            Buffer.ApplyTag(last_removed_tag, prev_line, prev_line_end);
                        }
                        else
                        {
                            Logger.Debug("Shouldn't ever hit this code (hopefully)");
                        }
                    }

                    last_removed_tag = null;
                }
            }
            else
            {
                ApplyTaskTagToBlock(ref start, args.Pos);
            }
        }
예제 #6
0
        void OnInsertText(object sender, Gtk.InsertTextArgs args)
        {
            Gtk.TextIter start;
            Gtk.TextIter end = args.Pos;
            end.BackwardChars(2);
            Gtk.TextIter iter = end;
            string       id;

            switch (end.Char)
            {
            case bold_id:
                id = bold_id;
                break;

            case italic_id:
                id = italic_id;
                break;

            case underlined_id:
                id = underlined_id;
                break;

            case highlight_id:
                id = highlight_id;
                break;

            case strikethrough_id:
                id = strikethrough_id;
                break;

            default:
                return;
            }

            /* TODO: Catch double "id" characters. ** should not be
             * detected
             */
            while (iter.LineOffset != 0)
            {
                iter.BackwardChar();
                if (iter.Char == id)
                {
                    start = iter;
                    iter.ForwardChar();
                    string text = Buffer.GetText(iter, end, false);
                    end.ForwardChar();
                    Gtk.TextTag tags;
                    switch (id)
                    {
                    case bold_id:
                        tags = (Gtk.TextTag)bold_tag;
                        break;

                    case italic_id:
                        tags = italic_tag;
                        break;

                    case underlined_id:
                        tags = underline_tag;
                        break;

                    case highlight_id:
                        tags = highlight_tag;
                        break;

                    case strikethrough_id:
                        tags = strikethrough_tag;
                        break;

                    default:
                        return;
                    }

                    Buffer.Delete(ref start, ref end);
                    Buffer.InsertWithTags(ref start, text, tags);
                    break;
                }
            }
        }
예제 #7
0
 protected virtual void OnInsertingText(Gtk.TextIter pos, string text)
 {
     if (InsertingText != null)
     {
         var args = new Gtk.InsertTextArgs { Args = new object[] { pos, text, text.Length, } };
         InsertingText(this, args);
     }
 }