protected override bool OnActivate(NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { string persona = start.GetText(end); PersonLink plink = (PersonLink)galago.Trie.Lookup(persona); try { plink.SendMessage(); } catch (Exception e) { string title = Catalog.GetString("Cannot contact '{0}'"); title = String.Format(title, persona); string message = Catalog.GetString("Error running gaim-remote: {0}"); message = String.Format(message, e.Message); Logger.Log(message); HIGMessageDialog dialog = new HIGMessageDialog(editor.Toplevel as Gtk.Window, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, title, message); dialog.Run(); dialog.Destroy(); } return(true); }
public void PreviousWord(object o, EventArgs args) { if (startWordIter.Equal(Gtk.TextIter.Zero)) { startWordIter = textBuffer.StartIter; } endWordIter = startWordIter; while (startWordIter.BackwardChar() && !startWordIter.StartsWord()) { } curWord = startWordIter.GetText(endWordIter); curWord = Regex.Replace(curWord, @"--", "", RegexOptions.Multiline); curWord = curWord.TrimStart(new char[5] { ' ', '\n', '\t', '\r', '-' }); curWord = curWord.TrimEnd(new char[5] { ' ', '\n', '\t', '\r', '-' }); curWord = Regex.Replace(curWord, @"\s+", " ", RegexOptions.Multiline); //Console.WriteLine("Word: \"" + curWord +"\""); ShowWord(curWord); HilightWord(); slideLock = true; slider.Value = endWordIter.Offset; slideLock = false; }
void HighlightInBlock(Gtk.TextIter start, Gtk.TextIter end) { foreach (TrieHit hit in galago.Trie.FindMatches(start.GetText(end))) { Gtk.TextIter match_start = Buffer.GetIterAtOffset(start.Offset + hit.Start); // Don't create links inside note or URL links if (match_start.HasTag(url_tag) || match_start.HasTag(link_tag)) { continue; } Gtk.TextIter match_end = match_start; match_end.ForwardChars(hit.End - hit.Start); Logger.Log("Matching Person '{0}' at {1}-{2}...", hit.Key, hit.Start, hit.End); Buffer.ApplyTag(person_tag, match_start, match_end); } }
public EraseAction (TextIter startIter, TextIter endIter, ChopBuffer chop_buf) { #if DEBUG Console.WriteLine ("DEBUG: EraseAction: {0}", startIter.GetText (endIter)); Console.WriteLine ("DEBUG: Start Offset: {0} Char: {1}", startIter.Offset, startIter.Char); Console.WriteLine ("DEBUG: End Offset: {0} Char: {1}", endIter.Offset, endIter.Char); #endif this.start = startIter.Offset; this.end = endIter.Offset; this.is_cut = end - start > 1; TextIter previousIter = startIter.Buffer.GetIterAtOffset (start - 1); bool startsRegion = previousIter.Char.Equals ("["); bool endsRegion = endIter.Char.Equals ("]"); this.whole_region = startsRegion && endsRegion; TextIter insert = startIter.Buffer.GetIterAtMark (startIter.Buffer.InsertMark); this.is_forward = insert.Offset <= start; this.chop = chop_buf.AddChop (startIter, endIter); }
private string GetUrl(TextIter start, TextIter end) { string url = start.GetText(end).Trim(); // Add to 'http://' to the front of www.foo.com // 'ftp://' to ftp.foo.com, // 'mailto:' to [email protected] if (url.StartsWith("www.")) { url = "http://" + url; } else if (url.StartsWith("ftp.")) { url = "ftp://" + url; } else if (url.IndexOf("@") > 1 && url.IndexOf(".") > 3 && !url.StartsWith("mailto:")) { url = "mailto:" + url; } return(url); }
public string GetNextWord() { Gtk.TextIter prevCharIter = new Gtk.TextIter(); Gtk.TextIter nextCharIter = new Gtk.TextIter(); Gtk.TextIter prevWordEndIter = new Gtk.TextIter(); string text; string word; bool bail = false; endPara = false; wao = 1; startWordIter = endWordIter; // Need to trap last word see gnomeRSVP if (!endWordIter.ForwardWordEnd()) { StopRsvp(null, null); } do { prevCharIter = endWordIter; prevCharIter.BackwardChar(); nextCharIter = endWordIter; nextCharIter.ForwardChar(); if (Regex.IsMatch(endWordIter.Char, @"^\S$", RegexOptions.None) && Regex.IsMatch(prevCharIter.Char, @"^\s$", RegexOptions.None)) { text = startWordIter.GetText(endWordIter); text = Regex.Replace(text, @"--", "", RegexOptions.Multiline); text = text.TrimStart(new char[4] { ' ', '\n', '\t', '-' }); text = Regex.Replace(text, @"\s+", " ", RegexOptions.Multiline); if (text.Length <= config.WordGroupSize) { if (endWordIter.InsideSentence()) { prevWordEndIter = prevCharIter; wao++; } } else { bail = true; nextCharIter.BackwardChar(); } } else if (endWordIter.EndsSentence()) { bail = true; do { } while (endWordIter.EndsSentence() && endWordIter.ForwardChar()); nextCharIter.BackwardChar(); if (!endWordIter.IsEnd) { if (nextCharIter.Char == "\n") { endPara = true; } } } endWordIter = nextCharIter; } while (!bail && !endWordIter.IsEnd); word = startWordIter.GetText(endWordIter); word = Regex.Replace(word, @"--", "", RegexOptions.Multiline); word = word.TrimStart(new char[4] { ' ', '\n', '\t', '-' }); word = Regex.Replace(word, @"\s+$", "", RegexOptions.Multiline); word = Regex.Replace(word, @"\s+", " ", RegexOptions.Multiline); if (word.Length > config.WordGroupSize && !prevWordEndIter.Equal(Gtk.TextIter.Zero)) { wao--; endWordIter = prevWordEndIter; } word = startWordIter.GetText(endWordIter); word = Regex.Replace(word, @"--", "", RegexOptions.Multiline); word = word.TrimStart(new char[4] { ' ', '\n', '\t', '-' }); word = Regex.Replace(word, @"\s+$", "", RegexOptions.Multiline); word = Regex.Replace(word, @"\s+", " ", RegexOptions.Multiline); if (endWordIter.IsEnd) { StopRsvp(null, null); } return(word); }