]> git.lyx.org Git - lyx.git/blob - src/support/os.h
0fce6c1d16fb8c035ceec20deef266589b8fdca8
[lyx.git] / src / support / os.h
1 // -*- C++ -*-
2 /**
3  * \file os.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Ruurd A. Reitsma
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  * wrap OS-specific stuff
12  */
13
14 #ifndef OS_H
15 #define OS_H
16
17 #include "support/docstring.h"
18
19 #include <string>
20
21
22 namespace lyx {
23 namespace support {
24 namespace os {
25
26 enum shell_type {
27         UNIX,   // Do we have to distinguish sh and csh?
28         CMD_EXE
29 };
30
31 /// Do some work just once.
32 void init(int argc, char * argv[]);
33
34 /// Returns the name of the NULL device (/dev/null, null).
35 std::string const & nulldev();
36
37 /// Returns "/" on *nix, "C:/", etc on Windows.
38 std::string current_root();
39
40 ///
41 shell_type shell();
42
43 /// Name of the python interpreter
44 std::string const python();
45
46 /// Extract the path common to both @c p1 and @c p2. DBCS aware!
47 std::string::size_type common_path(std::string const & p1, std::string const & p2);
48
49 /// Converts a unix style path to host OS style.
50 std::string external_path(std::string const & p);
51
52 /// Converts a host OS style path to unix style.
53 std::string internal_path(std::string const & p);
54
55 /// Converts a unix style path list to host OS style.
56 std::string external_path_list(std::string const & p);
57
58 /// Converts a host OS style path list to unix style.
59 std::string internal_path_list(std::string const & p);
60
61 /**
62  * Converts a unix style path into a form suitable for inclusion in a LaTeX
63  * document.
64  * Caution: This function handles only the OS specific part of that task.
65  * Never use it directly, use lyx::support::latex_path instead.
66  */
67 std::string latex_path(std::string const & p);
68
69 /// Is the path absolute?
70 bool is_absolute_path(std::string const & p);
71
72 /** Returns a string suitable to be passed to popen when
73  *  reading a file.
74  */
75 char const * popen_read_mode();
76
77 /** The character used to separate paths returned by the
78  *  PATH environment variable.
79  */
80 char path_separator();
81
82 /** If @c use_windows_paths is true, LyX will output Windows-style paths to
83  *  latex files rather than posix ones. Obviously, this option is used only
84  *  under Windows.
85  */
86 void windows_style_tex_paths(bool use_windows_paths);
87
88 enum auto_open_mode {
89         VIEW,
90         EDIT
91 };
92
93 /** Check whether or not a file can be opened by a default viewer or editor.
94  *  \param extension (without leading .)
95  *  \param mode can be opened in VIEW or EDIT mode
96  *  \returns whether or not the format can be opened according to \p mode
97  */
98 bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode = VIEW);
99
100 /** View or edit a file with the default viewer or editor.
101  *  \param filename file to open
102  *  \param mode open in VIEW or EDIT mode
103  *  \returns whether or not the file is viewed (or edited) successfully.
104  */
105 bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW);
106
107 /** General font utilities.
108  *  FIXME: only MAC and WIN32 for now but it would be nice to convince
109  *  fontconfig to do the same for linux.
110  */
111
112 /// Add fonts to the font subsystem, must be called before Application
113 /// is initialized.
114 void addFontResources();
115
116 /// Restore original font resources, must be called after Application
117 /// is destroyed.
118 void restoreFontResources();
119
120 } // namespace os
121 } // namespace support
122 } // namespace lyx
123
124 #endif