]> git.lyx.org Git - features.git/commitdiff
* Transfer LFUN_SERVER_GOTO_FILE_ROW to GuiView and clean it up a bit.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 23 Sep 2009 13:45:58 +0000 (13:45 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 23 Sep 2009 13:45:58 +0000 (13:45 +0000)
* Add a recenter() call to BufferView::setCursorFromRow() in order to get the screen centered around the found position.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31455 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/LyXFunc.cpp
src/Text3.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h

index bdfc1e59325ef66d9bf6b412ca9c350b56994e57..96094ea60539fda2c8c75df779d1bd1c6f21031a 100644 (file)
@@ -2058,6 +2058,7 @@ void BufferView::setCursorFromRow(int row)
                buffer_.text().setCursor(d->cursor_, 0, 0);
        else
                buffer_.text().setCursor(d->cursor_, buffer_.getParFromID(tmpid).pit(), tmppos);
+       recenter();
 }
 
 
index 4e6cdda3e9db1bcf76cfb959506ef20ba3d95736..19d2b086c430e0084d3023171c42dafa1d55658a 100644 (file)
@@ -458,7 +458,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_DROP_LAYOUTS_CHOICE:
        case LFUN_SERVER_GET_FILENAME:
        case LFUN_SERVER_NOTIFY:
-       case LFUN_SERVER_GOTO_FILE_ROW:
        case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
        case LFUN_REPEAT:
        case LFUN_PREFERENCES_SAVE:
@@ -592,60 +591,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        theServer().notifyClient(to_utf8(dispatch_buffer));
                        break;
 
-               case LFUN_SERVER_GOTO_FILE_ROW: {
-                       LASSERT(lv, /**/);
-                       string file_name;
-                       int row;
-                       istringstream is(argument);
-                       is >> file_name >> row;
-                       file_name = os::internal_path(file_name);
-                       Buffer * buf = 0;
-                       bool loaded = false;
-                       string const abstmp = package().temp_dir().absFilename();
-                       string const realtmp = package().temp_dir().realPath();
-                       // We have to use os::path_prefix_is() here, instead of
-                       // simply prefixIs(), because the file name comes from
-                       // an external application and may need case adjustment.
-                       if (os::path_prefix_is(file_name, abstmp, os::CASE_ADJUSTED)
-                           || os::path_prefix_is(file_name, realtmp, os::CASE_ADJUSTED)) {
-                               // Needed by inverse dvi search. If it is a file
-                               // in tmpdir, call the apropriated function.
-                               // If tmpdir is a symlink, we may have the real
-                               // path passed back, so we correct for that.
-                               if (!prefixIs(file_name, abstmp))
-                                       file_name = subst(file_name, realtmp, abstmp);
-                               buf = theBufferList().getBufferFromTmp(file_name);
-                       } else {
-                               // Must replace extension of the file to be .lyx
-                               // and get full path
-                               FileName const s = fileSearch(string(), changeExtension(file_name, ".lyx"), "lyx");
-                               // Either change buffer or load the file
-                               if (theBufferList().exists(s))
-                                       buf = theBufferList().getBuffer(s);
-                               else if (s.exists()) {
-                                       buf = lv->loadDocument(s);
-                                       loaded = true;
-                               } else
-                                       lv->message(bformat(
-                                               _("File does not exist: %1$s"),
-                                               makeDisplayPath(file_name)));
-                       }
-
-                       if (!buf) {
-                               updateFlags = Update::None;
-                               break;
-                       }
-
-                       buf->updateLabels();
-                       lv->setBuffer(buf);
-                       lv->documentBufferView()->setCursorFromRow(row);
-                       if (loaded)
-                               buf->errors("Parse");
-                       updateFlags = Update::FitCursor;
-                       break;
-               }
-
-
                case LFUN_DIALOG_SHOW_NEW_INSET: {
                        LASSERT(lv, /**/);
                        string const name = cmd.getArg(0);
index c1e89abd6a7f46b0afd0280725892121d158b6e1..587f90333b47952f8cb880ee13479d89b412edae 100644 (file)
@@ -2743,7 +2743,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_NOACTION:
        case LFUN_NOTE_NEXT:
        case LFUN_REFERENCE_NEXT:
-       case LFUN_SERVER_GOTO_FILE_ROW:
        case LFUN_SERVER_NOTIFY:
        case LFUN_SERVER_SET_XY:
        case LFUN_TEXTSTYLE_APPLY:
index b1bfd73d423c3479d49d644b429f6d72e470eae0..ceb5f8067ca4e5079fcfc3b46a139f1efbb3034f 100644 (file)
@@ -1424,6 +1424,9 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                break;
        }
 
+       case LFUN_SERVER_GOTO_FILE_ROW:
+               break;
+
        default:
                return false;
        }
@@ -2404,6 +2407,53 @@ void GuiView::openChildDocument(string const & fname)
 }
 
 
+bool GuiView::goToFileRow(string const & argument)
+{
+       string file_name;
+       int row;
+       istringstream is(argument);
+       is >> file_name >> row;
+       file_name = os::internal_path(file_name);
+       Buffer * buf = 0;
+       string const abstmp = package().temp_dir().absFilename();
+       string const realtmp = package().temp_dir().realPath();
+       // We have to use os::path_prefix_is() here, instead of
+       // simply prefixIs(), because the file name comes from
+       // an external application and may need case adjustment.
+       if (os::path_prefix_is(file_name, abstmp, os::CASE_ADJUSTED)
+               || os::path_prefix_is(file_name, realtmp, os::CASE_ADJUSTED)) {
+               // Needed by inverse dvi search. If it is a file
+               // in tmpdir, call the apropriated function.
+               // If tmpdir is a symlink, we may have the real
+               // path passed back, so we correct for that.
+               if (!prefixIs(file_name, abstmp))
+                       file_name = subst(file_name, realtmp, abstmp);
+               buf = theBufferList().getBufferFromTmp(file_name);
+       } else {
+               // Must replace extension of the file to be .lyx
+               // and get full path
+               FileName const s = fileSearch(string(),
+                                             support::changeExtension(file_name, ".lyx"), "lyx");
+               // Either change buffer or load the file
+               if (theBufferList().exists(s))
+                       buf = theBufferList().getBuffer(s);
+               else if (s.exists()) {
+                       buf = loadDocument(s);
+                       buf->updateLabels();
+                       buf->errors("Parse");
+               } else {
+                       message(bformat(
+                                       _("File does not exist: %1$s"),
+                                       makeDisplayPath(file_name)));
+                       return false;
+               }
+       }
+       setBuffer(buf);
+       documentBufferView()->setCursorFromRow(row);
+       return true;
+}
+
+
 bool GuiView::dispatch(FuncRequest const & cmd)
 {
        BufferView * bv = currentBufferView();
@@ -2725,6 +2775,10 @@ bool GuiView::dispatch(FuncRequest const & cmd)
                        dispatchVC(cmd);
                        break;
 
+               case LFUN_SERVER_GOTO_FILE_ROW:
+                       goToFileRow(to_utf8(cmd.argument()));
+                       break;
+
                default:
                        dispatched = false;
                        break;
index 06449a9174aa33b9d04227d3de8b684088732fad..82018505054b20e28e747bd3a5056f5cf38fa8e8 100644 (file)
@@ -200,6 +200,9 @@ private:
        bool event(QEvent * e);
        bool focusNextPrevChild(bool);
 
+       ///
+       bool goToFileRow(std::string const & argument);
+
        ///
        struct GuiViewPrivate;
        GuiViewPrivate & d;