]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_cb.C
more cursor dispatch
[lyx.git] / src / lyx_cb.C
index 216f3aca041ac02dca0e2b60064aeb1c53679c87..48ac377406df0ff2497807cf0c895cde8df6fd44 100644 (file)
@@ -19,6 +19,7 @@
 #include "buffer.h"
 #include "bufferlist.h"
 #include "BufferView.h"
+#include "cursor.h"
 #include "debug.h"
 #include "gettext.h"
 #include "lastfiles.h"
@@ -36,6 +37,7 @@
 #include "support/FileInfo.h"
 #include "support/filetools.h"
 #include "support/forkedcall.h"
+#include "support/globbing.h"
 #include "support/lyxlib.h"
 #include "support/os.h"
 #include "support/path.h"
@@ -48,6 +50,7 @@
 using lyx::support::AddName;
 using lyx::support::bformat;
 using lyx::support::destroyDir;
+using lyx::support::FileFilterList;
 using lyx::support::FileInfo;
 using lyx::support::ForkedProcess;
 using lyx::support::IsLyXFilename;
@@ -68,11 +71,12 @@ using lyx::support::user_lyxdir;
 
 namespace os = lyx::support::os;
 
+using std::auto_ptr;
 using std::back_inserter;
 using std::copy;
 using std::endl;
 using std::make_pair;
-
+using std::string;
 using std::ifstream;
 using std::ios;
 using std::istream_iterator;
@@ -90,7 +94,7 @@ bool quitting;        // flag, that we are quitting the program
 bool MenuWrite(Buffer * buffer)
 {
        if (buffer->save()) {
-               lastfiles->newFile(buffer->fileName());
+               LyX::ref().lastfiles().newFile(buffer->fileName());
                return true;
        }
 
@@ -127,10 +131,12 @@ bool WriteAs(Buffer * buffer, string const & filename)
                if (!IsLyXFilename(fname))
                        fname += ".lyx";
 
+               FileFilterList const filter (_("LyX Documents (*.lyx)"));
+
                FileDialog::Result result =
                        fileDlg.save(OnlyPath(fname),
-                                      _("*.lyx| LyX Documents (*.lyx)"),
-                                      OnlyFilename(fname));
+                                    filter,
+                                    OnlyFilename(fname));
 
                if (result.first == FileDialog::Later)
                        return false;
@@ -184,7 +190,7 @@ void QuitLyX()
                if (!bufferlist.quitWriteAll())
                        return;
 
-               lastfiles->writeFile(lyxrc.lastfiles);
+               LyX::cref().lastfiles().writeFile(lyxrc.lastfiles);
        }
 
        // Set a flag that we do quitting from the program,
@@ -215,8 +221,8 @@ public:
        AutoSaveBuffer(BufferView & bv, string const & fname)
                : bv_(bv), fname_(fname) {}
        ///
-       virtual ForkedProcess * clone() const {
-               return new AutoSaveBuffer(*this);
+       virtual auto_ptr<ForkedProcess> clone() const {
+               return auto_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
        }
        ///
        int start();
@@ -352,13 +358,12 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
                return;
 
        // clear the selection
-       bool flag = (bv->text == bv->getLyXText());
-       if (flag)
-               bv->beforeChange(bv->text);
-       if (!asParagraph)
-               bv->getLyXText()->insertStringAsLines(tmpstr);
-       else
+       if (bv->text() == bv->getLyXText())
+               bv->cursor().clearSelection();
+       if (asParagraph)
                bv->getLyXText()->insertStringAsParagraphs(tmpstr);
+       else
+               bv->getLyXText()->insertStringAsLines(tmpstr);
        bv->update();
 }
 
@@ -372,7 +377,9 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
                FileDialog fileDlg(_("Select file to insert"),
                        (asParagraph) ? LFUN_FILE_INSERT_ASCII_PARA : LFUN_FILE_INSERT_ASCII);
 
-               FileDialog::Result result = fileDlg.open(bv->owner()->buffer()->filePath());
+               FileDialog::Result result =
+                       fileDlg.open(bv->owner()->buffer()->filePath(),
+                                    FileFilterList(), string());
 
                if (result.first == FileDialog::Later)
                        return string();
@@ -427,8 +434,8 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
 
 string const getPossibleLabel(BufferView const & bv)
 {
-       ParagraphList::iterator pit = bv.getLyXText()->cursor.par();
-       ParagraphList & plist = bv.getLyXText()->ownerParagraphs();
+       ParagraphList::iterator pit = bv.getLyXText()->cursorPar();
+       ParagraphList & plist = bv.getLyXText()->paragraphs();
 
        LyXLayout_ptr layout = pit->layout();
 
@@ -458,9 +465,9 @@ string const getPossibleLabel(BufferView const & bv)
                        break;
                string head;
                par_text = split(par_text, head, ' ');
+               // Is it legal to use spaces in labels ?
                if (i > 0)
-                       text += '-'; // Is it legal to use spaces in
-               // labels ?
+                       text += '-';
                text += head;
        }