]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/stc.cpp.in
rtti api mods added
[wxWidgets.git] / src / stc / stc.cpp.in
index 66434747989357d29e48838b585aff223876d947..60360d977e0f607e354712e0ee6c4c37496c4a18 100644 (file)
@@ -24,6 +24,7 @@
 #include <wx/tokenzr.h>
 #include <wx/mstream.h>
 #include <wx/image.h>
+#include <wx/file.h>
 
 
 //----------------------------------------------------------------------
@@ -307,6 +308,51 @@ void wxStyledTextCtrl::ScrollToColumn(int column) {
 }
 
 
+bool wxStyledTextCtrl::SaveFile(const wxString& filename)
+{
+    wxFile file(filename, wxFile::write);
+
+    if (!file.IsOpened())
+        return FALSE;
+
+    bool success = file.Write(GetText());
+
+    if (success)
+        SetSavePoint();
+
+    return success;
+}
+
+bool wxStyledTextCtrl::LoadFile(const wxString& filename)
+{
+    bool success = false;
+    wxFile file(filename, wxFile::read);
+
+    if (file.IsOpened())
+    {
+        wxString contents;
+        off_t len = file.Length();
+
+        if (len > 0)
+        {
+            wxChar *buf = contents.GetWriteBuf(len);
+            success = (file.Read(buf, len) == len);
+            contents.UngetWriteBuf();
+        }
+        else
+            success = true;            // empty file is ok
+
+        if (success)
+        {
+            SetText(contents);
+            EmptyUndoBuffer();
+            SetSavePoint();
+        }
+    }
+
+    return success;
+}
+
 
 //----------------------------------------------------------------------
 // Event handlers