diff --git a/Terminal.Gui/Views/Clipboard.cs b/Terminal.Gui/Views/Clipboard.cs index f518ebc9e..be6000269 100644 --- a/Terminal.Gui/Views/Clipboard.cs +++ b/Terminal.Gui/Views/Clipboard.cs @@ -1,8 +1,8 @@ using System; +using NStack; + namespace Terminal.Gui { public class Clipboard { - public Clipboard () - { - } + public static ustring Contents { get; set; } } } diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index 09dea1bf2..c6ae784b0 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -19,7 +19,7 @@ namespace Terminal.Gui { /// functionality, and mouse support. /// public class TextField : View { - ustring text, kill; + ustring text; int first, point; bool used; @@ -125,6 +125,12 @@ namespace Terminal.Gui { set { base.CanFocus = value; } } + void SetClipboard (ustring text) + { + if (!Secret) + Clipboard.Contents = text; + } + public override bool ProcessKey (KeyEvent kb) { switch (kb.Key) { @@ -174,21 +180,22 @@ namespace Terminal.Gui { break; case Key.ControlK: // kill-to-end - kill = text.Substring (point); + SetClipboard (text.Substring (point)); SetText (text [0, point]); Adjust (); break; case Key.ControlY: // Control-y, yank - if (kill == null) + var clip = Clipboard.Contents; + if (clip== null) return true; if (point == text.Length) { - SetText (text + kill); + SetText (text + clip); point = text.Length; } else { - SetText (text [0, point] + kill + text.Substring (point)); - point += kill.Length; + SetText (text [0, point] + clip + text.Substring (point)); + point += clip.RuneCount; } Adjust (); break; @@ -207,6 +214,11 @@ namespace Terminal.Gui { Adjust (); break; + // MISSING: + // Alt-D, Alt-backspace + // Alt-Y + // Delete adding to kill buffer + default: // Ignore other control characters. if (kb.Key < Key.Space || kb.Key > Key.CharMask)