/// <summary> /// Pastes text from the clipboard. /// </summary> /// <returns> /// <c>true</c>, if the paste was successfully performed, <c>false</c> otherwise. /// </returns> public bool PerformPaste(Gtk.Clipboard clipboard) { string txt = string.Empty; txt = clipboard.WaitForText (); if (String.IsNullOrEmpty (txt)) return false; string[] ins_lines = txt.Split (Environment.NewLine.ToCharArray (), StringSplitOptions.None); string endline = lines [linePos].Substring (textPos); lines [linePos] = lines [linePos].Substring (0, textPos); bool first = true; foreach (string ins_txt in ins_lines) { if (!first) { linePos++; lines.Insert (linePos, ins_txt); textPos = ins_txt.Length; } else { first = false; lines[linePos] += ins_txt; textPos += ins_txt.Length; } } lines [linePos] += endline; textMode = TextMode.Uncommitted; Recalculate (); return true; }
/// <summary> /// Pastes text from the clipboard. /// </summary> /// <returns> /// <c>true</c>, if the paste was successfully performed, <c>false</c> otherwise. /// </returns> public bool PerformPaste (Gtk.Clipboard clipboard) { string txt = string.Empty; txt = clipboard.WaitForText (); if (String.IsNullOrEmpty (txt)) return false; if (HasSelection ()) DeleteSelection (); string[] ins_lines = txt.Split (Environment.NewLine.ToCharArray (), StringSplitOptions.RemoveEmptyEntries); string endline = lines [currentPos.Line].Substring (currentPos.Offset); lines [currentPos.Line] = lines [currentPos.Line].Substring (0, currentPos.Offset); bool first = true; foreach (string ins_txt in ins_lines) { if (!first) { currentPos.Line++; lines.Insert (currentPos.Line, ins_txt); currentPos.Offset = ins_txt.Length; } else { first = false; lines[currentPos.Line] += ins_txt; currentPos.Offset += ins_txt.Length; } } lines [currentPos.Line] += endline; selectionStart = currentPos; State = TextMode.Uncommitted; OnModified (); return true; }