]> git.lyx.org Git - lyx.git/blobdiff - src/support/Package.h
Account for old versions of Pygments
[lyx.git] / src / support / Package.h
index bfd359faf186898153da81800bc961fe08a7dc9b..4e5c6fa3f46e78f11ba64ab80ca0304ae5e017bf 100644 (file)
@@ -25,14 +25,6 @@ namespace support {
 
 class Package;
 
-/** When run in-place <build-dir>/src/lyx is one level up from
- *  the <build-dir> whilst <build-dir>/src/tex2lyx/tex2lyx is
- *  two levels up.
- */
-enum exe_build_dir_to_top_build_dir {
-       top_build_dir_is_one_level_up,
-       top_build_dir_is_two_levels_up
-};
 
 
 /** Initialise package() with the command line data.
@@ -49,8 +41,7 @@ enum exe_build_dir_to_top_build_dir {
  */
 void init_package(std::string const & command_line_arg0,
                  std::string const & command_line_system_support_dir,
-                 std::string const & command_line_user_support_dir,
-                 exe_build_dir_to_top_build_dir);
+                 std::string const & command_line_user_support_dir);
 
 /** Accessor to the global data.
  *  Asserts that init_package() has been called first.
@@ -60,20 +51,28 @@ Package const & package();
 class Package {
 public:
        /// Default constructor does not lead to the paths being set.
-       Package() {}
+       Package() : explicit_user_support_dir_(false), in_build_dir_(false) {}
 
        /** Called by init_package, above.
         *  All paths will be initialized.
         */
        Package(std::string const & command_line_arg0,
                std::string const & command_line_system_support_dir,
-               std::string const & command_line_user_support_dir,
-               exe_build_dir_to_top_build_dir);
+               std::string const & command_line_user_support_dir);
 
-       /** The directory containing the LyX executable.
+       /** The directory containing the main executable (LyX or tex2lyx).
         */
        FileName const & binary_dir() const { return binary_dir_; }
 
+       /** The absolute path to the LyX executable.
+        */
+       FileName const & lyx_binary() const { return lyx_binary_; }
+
+       /** The absolute path to the LyX package directory.
+        *  This is one level up from the binary dir.
+        */
+       FileName const & lyx_dir() const { return lyx_dir_; }
+
        /** The top of the LyX source code tree.
         */
        static FileName const & top_srcdir();
@@ -94,7 +93,7 @@ public:
 
        /** The user_support directory was set explicitly using either
         *  the -userdir command line switch or
-        *  the LYX_USERDIR_15x environment variable.
+        *  the LYX_USERDIR_${major}${minor}x environment variable.
         */
        bool explicit_user_support() const { return explicit_user_support_dir_; }
 
@@ -102,6 +101,12 @@ public:
         */
        FileName const & locale_dir() const { return locale_dir_; }
 
+       /** The file name that should contain the message file (.mo)
+        *  for language code \param c. Does not check whether the
+        *  file exists. Handles running in place.
+        */
+       FileName messages_file(std::string const & c) const;
+
        /** The default document directory.
         *  Can be reset by LyXRC.
         */
@@ -112,11 +117,14 @@ public:
         */
        FileName const & system_temp_dir() const { return system_temp_dir_; }
 
-       /** The path to the temporary directory used by LyX.
+       //@{
+       /** The path to the temporary directory used by %LyX.
         *  (Eg /tmp/lyx_tmpdir800nBI1z9 on *nix.)
         *  Can be reset by LyXRC.
         */
-       FileName & temp_dir() const { return temp_dir_; }
+       FileName const & temp_dir() const { return temp_dir_; }
+       void set_temp_dir(FileName const & temp_dir) const;
+       //@}
 
        /** Used when setting the user_support directory.
         *  Used also when expanding "~/" or contracting to "~/". (filetools.cpp)
@@ -124,16 +132,18 @@ public:
         *  for the dump.
         *  This may be empty (e. g. when run under a CGI environment)
         */
-       FileName const & home_dir() const { return home_dir_; }
+       static FileName const & get_home_dir();
 
-       /** Command to run the configure script.
-        *  Caution: This is "ready-to-run", i.e. in the locale encoding, not
-        *  utf8.
-        */
-       std::string const & configure_command() const { return configure_command_; }
+       /// Run configure.py
+       int reconfigureUserLyXDir(std::string const & option) const;
+
+       ///
+       std::string getConfigureLockName() const;
 
 private:
        FileName binary_dir_;
+       FileName lyx_binary_;
+       FileName lyx_dir_;
        FileName system_support_dir_;
        FileName build_support_dir_;
        FileName user_support_dir_;
@@ -141,9 +151,13 @@ private:
        mutable FileName document_dir_;
        mutable FileName temp_dir_;
        FileName system_temp_dir_;
-       FileName home_dir_;
-       std::string configure_command_;
+       /** Command to run the configure script.
+        *  Caution: This is "ready-to-run", i.e. in the locale encoding, not
+        *  utf8.
+        */
+       mutable std::string configure_command_;
        bool explicit_user_support_dir_;
+       bool in_build_dir_;
 };
 
 } // namespace support