From 045bb85108e65a3fc4dce9ccd7f02cbeaf35c33d Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 22 Mar 2018 12:01:47 -0400 Subject: [PATCH] Save --- Terminal.Gui/Views/TextView.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index 3adedaedf..b5ca54651 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -15,6 +15,7 @@ // keybindings to go to top/bottom // public API to insert, remove ranges // Add word forward/word backwards commands +// Save buffer API using System; using System.Collections.Generic; @@ -286,6 +287,36 @@ namespace Terminal.Gui { } } + /// + /// Loads the contents of the file into the TextView. + /// + /// true, if file was loaded, false otherwise. + /// Path to the file to load. + public bool LoadFile (string path) + { + if (path == null) + throw new ArgumentNullException (nameof (path)); + ResetPosition (); + var res = model.LoadFile (path); + SetNeedsDisplay (); + return res; + } + + /// + /// Loads the contents of the stream into the TextView. + /// + /// true, if stream was loaded, false otherwise. + /// Stream. + public bool LoadStream (Stream stream) + { + if (stream == null) + throw new ArgumentNullException (nameof (stream)); + ResetPosition (); + var res = model.LoadFile (path); + SetNeedsDisplay (); + return res; + } + /// /// The current cursor row. ///