]> git.lyx.org Git - lyx.git/blob - src/support/os_win32.cpp
Remove updateInfo() calls in favor of doing the relevant work
[lyx.git] / src / support / os_win32.cpp
1 /**
2  * \file os_win32.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Ruurd A. Reitsma
7  * \author Claus Hentschel
8  * \author Angus Leeming
9  * \author Enrico Forestieri
10  *
11  * Full author contact details are available in file CREDITS.
12  *
13  * Various OS specific functions
14  */
15
16 #include <config.h>
17
18 #include "LyXRC.h"
19
20 #include "support/os.h"
21 #include "support/os_win32.h"
22
23 #include "support/debug.h"
24 #include "support/environment.h"
25 #include "support/FileName.h"
26 #include "support/gettext.h"
27 #include "support/filetools.h"
28 #include "support/lstrings.h"
29 #include "support/ExceptionMessage.h"
30 #include "support/qstring_helpers.h"
31
32 #include "support/lassert.h"
33
34 #include <cstdlib>
35 #include <vector>
36
37 #include <QString>
38
39 #include <io.h>
40 #include <direct.h> // _getdrive
41 #include <shlobj.h>  // SHGetFolderPath
42 #include <windef.h>
43 #include <shellapi.h>
44 #include <shlwapi.h>
45
46 // Must define SHGFP_TYPE_CURRENT for older versions of MinGW.
47 #if defined(__MINGW32__)  || defined(__CYGWIN__) || defined(__CYGWIN32__)
48 # include <w32api.h>
49 # if __W32API_MAJOR_VERSION < 3 || \
50      __W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION  < 2
51 #  define SHGFP_TYPE_CURRENT 0
52 # endif
53 #endif
54
55 #if !defined(ASSOCF_INIT_IGNOREUNKNOWN) && !defined(__MINGW32__)
56 #define ASSOCF_INIT_IGNOREUNKNOWN 0
57 #endif
58
59 #if defined(__MINGW32__)
60 #include <stdio.h>
61 #endif
62
63 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
64 #else
65 extern "C" {
66 extern void __wgetmainargs(int * argc, wchar_t *** argv, wchar_t *** envp,
67                            int expand_wildcards, int * new_mode);
68 }
69 #endif
70
71 using namespace std;
72
73 namespace lyx {
74
75 void lyx_exit(int);
76
77 namespace support {
78 namespace os {
79
80 namespace {
81
82 int argc_ = 0;
83 wchar_t ** argv_ = 0;
84
85 bool windows_style_tex_paths_ = true;
86
87 string cygdrive = "/cygdrive";
88
89 BOOL terminate_handler(DWORD event)
90 {
91         if (event == CTRL_CLOSE_EVENT
92             || event == CTRL_LOGOFF_EVENT
93             || event == CTRL_SHUTDOWN_EVENT) {
94                 lyx::lyx_exit(1);
95                 return TRUE;
96         }
97         return FALSE;
98 }
99
100 } // namespace
101
102 void init(int argc, char ** argv[])
103 {
104         /* Note from Angus, 17 Jan 2005:
105          *
106          * The code below is taken verbatim from Ruurd's original patch
107          * porting LyX to Win32.
108          *
109          * Windows allows us to define LyX either as a console-based app
110          * or as a GUI-based app. Ruurd decided to define LyX as a
111          * console-based app with a "main" function rather than a "WinMain"
112          * function as the point of entry to the program, but to
113          * immediately close the console window that Windows helpfully
114          * opens for us. Doing so allows the user to see all of LyX's
115          * debug output simply by running LyX from a DOS or MSYS-shell
116          * prompt.
117          *
118          * The alternative approach is to define LyX as a genuine
119          * GUI-based app, with a "WinMain" function as the entry point to the
120          * executable rather than a "main" function, so:
121          *
122          * #if defined (_WIN32)
123          * # define WIN32_LEAN_AND_MEAN
124          * # include <stdlib.h>  // for __argc, __argv
125          * # include <windows.h> // for WinMain
126          * #endif
127          *
128          * // This will require the "-mwindows" flag when linking with
129          * // gcc under MinGW.
130          * // For MSVC, use "/subsystem:windows".
131          * #if defined (_WIN32)
132          * int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
133          * {
134          *     return mymain(__argc, __argv);
135          * }
136          * #endif
137          *
138          * where "mymain" is just a renamed "main".
139          *
140          * However, doing so means that the lyxerr messages would mysteriously
141          * disappear. They could be resurrected with something like:
142          *
143          * #ifdef WIN32
144          *  AllocConsole();
145          *  freopen("conin$","r",stdin);
146          *  freopen("conout$","w",stdout);
147          *  freopen("conout$","w",stderr);
148          * #endif
149          *
150          * This code could be invoked (say) the first time that lyxerr
151          * is called. However, Ruurd has tried this route and found that some
152          * shell scripts failed, for mysterious reasons...
153          *
154          * I've chosen for now, therefore, to simply add Ruurd's original
155          * code as-is. A wrapper program hidecmd.c has been added to
156          * development/Win32 which hides the console window of lyx when
157          * lyx is invoked as a parameter of hidecmd.exe.
158          */
159
160
161 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
162         // Removing an argument from argv leads to an assertion on Windows
163         // when compiling with MSVC 2015 in debug mode (see bug #10440).
164         // To avoid this we make a copy of the array of pointers.
165         char ** newargv = (char **) malloc((argc + 1) * sizeof(char *));
166         if (newargv) {
167                 memcpy(newargv, *argv, (argc + 1) * sizeof(char *));
168                 *argv = newargv;
169         } else {
170                 lyxerr << "LyX warning: Cannot make a copy of "
171                           "command line arguments!"
172                        << endl;
173         }
174 #endif
175
176
177         // Get the wide program arguments array
178 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
179         argv_ = CommandLineToArgvW(GetCommandLineW(), &argc_);
180 #else
181         wchar_t ** envp = 0;
182         int newmode = 0;
183         __wgetmainargs(&argc_, &argv_, &envp, -1, &newmode);
184 #endif
185         LATTEST(argc == argc_);
186
187         // If Cygwin is detected, query the cygdrive prefix.
188         // The cygdrive prefix is needed for translating windows style paths
189         // to posix style paths in LaTeX files when the Cygwin teTeX is used.
190         int i;
191         HKEY hkey;
192         char buf[MAX_PATH];
193         DWORD bufsize = sizeof(buf);
194         LONG retval = ERROR_FILE_NOT_FOUND;
195         HKEY const mainkey[2] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER };
196         char const * const subkey[2] = {
197                 "Software\\Cygwin\\setup",                         // Cygwin 1.7
198                 "Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/" // Prev. ver.
199         };
200         char const * const valuename[2] = {
201                 "rootdir", // Cygwin 1.7 or later
202                 "native"   // Previous versions
203         };
204         // Check for newer Cygwin versions first, then older ones
205         for (i = 0; i < 2 && retval != ERROR_SUCCESS; ++i) {
206                 for (int k = 0; k < 2 && retval != ERROR_SUCCESS; ++k)
207                         retval = RegOpenKey(mainkey[k], subkey[i], &hkey);
208         }
209         if (retval == ERROR_SUCCESS) {
210                 // Query the Cygwin root directory
211                 retval = RegQueryValueEx(hkey, valuename[i - 1],
212                                 NULL, NULL, (LPBYTE) buf, &bufsize);
213                 RegCloseKey(hkey);
214                 string const mount = string(buf) + "\\bin\\mount.exe";
215                 if (retval == ERROR_SUCCESS && FileName(mount).exists()) {
216                         cmd_ret const p =
217                                 runCommand(mount + " --show-cygdrive-prefix");
218                         // The output of the mount command is as follows:
219                         // Prefix              Type         Flags
220                         // /cygdrive           system       binmode
221                         // So, we use the inner split to pass the second line
222                         // to the outer split which sets cygdrive with its
223                         // contents until the first blank, discarding the
224                         // unneeded return value.
225                         if (p.first != -1 && prefixIs(p.second, "Prefix"))
226                                 split(split(p.second, '\n'), cygdrive, ' ');
227                 }
228         }
229
230         // Catch shutdown events.
231         SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, TRUE);
232 }
233
234
235 string utf8_argv(int i)
236 {
237         LASSERT(i < argc_, return "");
238         return fromqstr(QString::fromWCharArray(argv_[i]));
239 }
240
241
242 void remove_internal_args(int i, int num)
243 {
244         argc_ -= num;
245         for (int j = i; j < argc_; ++j)
246                 argv_[j] = argv_[j + num];
247 }
248
249
250 string current_root()
251 {
252         // _getdrive returns the current drive (1=A, 2=B, and so on).
253         char const drive = ::_getdrive() + 'A' - 1;
254         return string(1, drive) + ":/";
255 }
256
257
258 bool isFilesystemCaseSensitive()
259 {
260         return false;
261 }
262
263
264 docstring::size_type common_path(docstring const & p1, docstring const & p2)
265 {
266         size_t i = 0;
267         size_t const p1_len = p1.length();
268         size_t const p2_len = p2.length();
269         while (i < p1_len && i < p2_len && uppercase(p1[i]) == uppercase(p2[i]))
270                 ++i;
271         if ((i < p1_len && i < p2_len)
272             || (i < p1_len && p1[i] != '/' && i == p2_len)
273             || (i < p2_len && p2[i] != '/' && i == p1_len))
274         {
275                 if (i)
276                         --i;     // here was the last match
277                 while (i && p1[i] != '/')
278                         --i;
279         }
280         return i;
281 }
282
283
284 bool path_prefix_is(string const & path, string const & pre)
285 {
286         return path_prefix_is(const_cast<string &>(path), pre, CASE_UNCHANGED);
287 }
288
289
290 bool path_prefix_is(string & path, string const & pre, path_case how)
291 {
292         docstring const p1 = from_utf8(path);
293         docstring const p2 = from_utf8(pre);
294         docstring::size_type const p1_len = p1.length();
295         docstring::size_type const p2_len = p2.length();
296         docstring::size_type common_len = common_path(p1, p2);
297
298         if (p2[p2_len - 1] == '/' && p1_len != p2_len)
299                 ++common_len;
300
301         if (common_len != p2_len)
302                 return false;
303
304         if (how == CASE_ADJUSTED && !prefixIs(path, pre)) {
305                 if (p1_len < common_len)
306                         path = to_utf8(p2.substr(0, p1_len));
307                 else
308                         path = to_utf8(p2 + p1.substr(common_len,
309                                                         p1_len - common_len));
310         }
311
312         return true;
313 }
314
315
316 string external_path(string const & p)
317 {
318         string const dos_path = subst(p, "/", "\\");
319
320         LYXERR(Debug::LATEX, "<Win32 path correction> ["
321                 << p << "]->>[" << dos_path << ']');
322         return dos_path;
323 }
324
325
326 static QString const get_long_path(QString const & short_path)
327 {
328         // GetLongPathNameW needs the path in utf16 encoding.
329         vector<wchar_t> long_path(MAX_PATH);
330         DWORD result = GetLongPathNameW((wchar_t *) short_path.utf16(),
331                                        &long_path[0], long_path.size());
332
333         if (result > long_path.size()) {
334                 long_path.resize(result);
335                 result = GetLongPathNameW((wchar_t *) short_path.utf16(),
336                                          &long_path[0], long_path.size());
337                 LATTEST(result <= long_path.size());
338         }
339
340         return (result == 0) ? short_path : QString::fromWCharArray(&long_path[0]);
341 }
342
343
344 static QString const get_short_path(QString const & long_path, file_access how)
345 {
346         // CreateFileW and GetShortPathNameW need the path in utf16 encoding.
347         if (how == CREATE) {
348                 HANDLE h = CreateFileW((wchar_t *) long_path.utf16(),
349                                 GENERIC_WRITE, 0, NULL, CREATE_NEW,
350                                 FILE_ATTRIBUTE_NORMAL, NULL);
351                 if (h == INVALID_HANDLE_VALUE
352                     && GetLastError() != ERROR_FILE_EXISTS)
353                         return long_path;
354                 CloseHandle(h);
355         }
356         vector<wchar_t> short_path(MAX_PATH);
357         DWORD result = GetShortPathNameW((wchar_t *) long_path.utf16(),
358                                        &short_path[0], short_path.size());
359
360         if (result > short_path.size()) {
361                 short_path.resize(result);
362                 result = GetShortPathNameW((wchar_t *) long_path.utf16(),
363                                          &short_path[0], short_path.size());
364                 LATTEST(result <= short_path.size());
365         }
366
367         return (result == 0) ? long_path : QString::fromWCharArray(&short_path[0]);
368 }
369
370
371 string internal_path(string const & p)
372 {
373         return subst(fromqstr(get_long_path(toqstr(p))), "\\", "/");
374 }
375
376
377 string safe_internal_path(string const & p, file_access how)
378 {
379         return subst(fromqstr(get_short_path(toqstr(p), how)), "\\", "/");
380 }
381
382
383 string external_path_list(string const & p)
384 {
385         return subst(p, '/', '\\');
386 }
387
388
389 string internal_path_list(string const & p)
390 {
391         return subst(p, '\\', '/');
392 }
393
394
395 string latex_path(string const & p)
396 {
397         // We may need a posix style path or a windows style path (depending
398         // on windows_style_tex_paths_), but we use always forward slashes,
399         // since it gets written into a .tex file.
400
401         if (!windows_style_tex_paths_ && FileName::isAbsolute(p)) {
402                 string const drive = p.substr(0, 2);
403                 string const cygprefix = cygdrive + "/" + drive.substr(0, 1);
404                 string const cygpath = subst(subst(p, '\\', '/'), drive, cygprefix);
405                 LYXERR(Debug::LATEX, "<Path correction for LaTeX> ["
406                         << p << "]->>[" << cygpath << ']');
407                 return cygpath;
408         }
409         return subst(p, '\\', '/');
410 }
411
412
413 string latex_path_list(string const & p)
414 {
415         if (p.empty())
416                 return p;
417
418         // We may need a posix style path or a windows style path (depending
419         // on windows_style_tex_paths_), but we use always forward slashes,
420         // since this is standard for all tex engines.
421
422         if (!windows_style_tex_paths_) {
423                 string pathlist;
424                 for (size_t i = 0, k = 0; i != string::npos; k = i) {
425                         i = p.find(';', i);
426                         string path = subst(p.substr(k, i - k), '\\', '/');
427                         if (FileName::isAbsolute(path)) {
428                                 string const drive = path.substr(0, 2);
429                                 string const cygprefix = cygdrive + "/"
430                                                         + drive.substr(0, 1);
431                                 path = subst(path, drive, cygprefix);
432                         }
433                         pathlist += path;
434                         if (i != string::npos) {
435                                 pathlist += ':';
436                                 ++i;
437                         }
438                 }
439                 return pathlist;
440         }
441         return subst(p, '\\', '/');
442 }
443
444
445 bool is_valid_strftime(string const & p)
446 {
447         string::size_type pos = p.find_first_of('%');
448         while (pos != string::npos) {
449                 if (pos + 1 == string::npos)
450                         break;
451                 if (!containsOnly(p.substr(pos + 1, 1),
452                         "aAbBcdfHIjmMpSUwWxXyYzZ%"))
453                         return false;
454                 if (pos + 2 == string::npos)
455                       break;
456                 pos = p.find_first_of('%', pos + 2);
457         }
458         return true;
459 }
460
461
462 // returns a string suitable to be passed to popen when
463 // reading a pipe
464 char const * popen_read_mode()
465 {
466         return "r";
467 }
468
469
470 string const & nulldev()
471 {
472         static string const nulldev_ = "nul";
473         return nulldev_;
474 }
475
476
477 shell_type shell()
478 {
479         return CMD_EXE;
480 }
481
482
483 char path_separator(path_type type)
484 {
485         if (type == TEXENGINE)
486                 return windows_style_tex_paths_ ? ';' : ':';
487
488         return ';';
489 }
490
491
492 void windows_style_tex_paths(bool use_windows_paths)
493 {
494         windows_style_tex_paths_ = use_windows_paths;
495 }
496
497
498 GetFolderPath::GetFolderPath()
499         : folder_module_(0),
500           folder_path_func_(0)
501 {
502         folder_module_ = LoadLibrary("shfolder.dll");
503         if (!folder_module_) {
504                 throw ExceptionMessage(ErrorException, _("System file not found"),
505                         _("Unable to load shfolder.dll\nPlease install."));
506         }
507
508         folder_path_func_ = reinterpret_cast<function_pointer>(::GetProcAddress(folder_module_, "SHGetFolderPathA"));
509         if (folder_path_func_ == 0) {
510                 throw ExceptionMessage(ErrorException, _("System function not found"),
511                         _("Unable to find SHGetFolderPathA in shfolder.dll\n"
512                           "Don't know how to proceed. Sorry."));
513         }
514 }
515
516
517 GetFolderPath::~GetFolderPath()
518 {
519         if (folder_module_)
520                 FreeLibrary(folder_module_);
521 }
522
523
524 // Given a folder ID, returns the folder name (in unix-style format).
525 // Eg CSIDL_PERSONAL -> "C:/Documents and Settings/USERNAME/My Documents"
526 string const GetFolderPath::operator()(folder_id _id) const
527 {
528         char folder_path[MAX_PATH];
529
530         int id = 0;
531         switch (_id) {
532         case PERSONAL:
533                 id = CSIDL_PERSONAL;
534                 break;
535         case APPDATA:
536                 id = CSIDL_APPDATA;
537                 break;
538         default:
539                 LASSERT(false, return string());
540         }
541         HRESULT const result = (folder_path_func_)(0, id, 0,
542                                                    SHGFP_TYPE_CURRENT,
543                                                    folder_path);
544         return (result == 0) ? os::internal_path(to_utf8(from_filesystem8bit(folder_path))) : string();
545 }
546
547
548 bool canAutoOpenFile(string const & ext, auto_open_mode const mode)
549 {
550         if (ext.empty())
551                 return false;
552
553         string const full_ext = "." + ext;
554
555         DWORD bufSize = MAX_PATH + 100;
556         TCHAR buf[MAX_PATH + 100];
557         // reference: http://msdn.microsoft.com/en-us/library/bb773471.aspx
558         char const * action = (mode == VIEW) ? "open" : "edit";
559         return S_OK == AssocQueryString(ASSOCF_INIT_IGNOREUNKNOWN,
560                 ASSOCSTR_EXECUTABLE, full_ext.c_str(), action, buf, &bufSize);
561 }
562
563
564 bool autoOpenFile(string const & filename, auto_open_mode const mode,
565                   string const & path)
566 {
567         string const texinputs = os::latex_path_list(
568                         replaceCurdirPath(path, lyxrc.texinputs_prefix));
569         string const otherinputs = os::latex_path_list(path);
570         string const sep = windows_style_tex_paths_ ? ";" : ":";
571         string const oldtexinputs = getEnv("TEXINPUTS");
572         string const newtexinputs = "." + sep + texinputs + sep + oldtexinputs;
573         string const oldbibinputs = getEnv("BIBINPUTS");
574         string const newbibinputs = "." + sep + otherinputs + sep + oldbibinputs;
575         string const oldbstinputs = getEnv("BSTINPUTS");
576         string const newbstinputs = "." + sep + otherinputs + sep + oldbstinputs;
577         string const oldtexfonts = getEnv("TEXFONTS");
578         string const newtexfonts = "." + sep + otherinputs + sep + oldtexfonts;
579         if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
580                 setEnv("TEXINPUTS", newtexinputs);
581                 setEnv("BIBINPUTS", newbibinputs);
582                 setEnv("BSTINPUTS", newbstinputs);
583                 setEnv("TEXFONTS", newtexfonts);
584         }
585
586         QString const wname = toqstr(filename);
587
588         // reference: http://msdn.microsoft.com/en-us/library/bb762153.aspx
589         wchar_t const * action = (mode == VIEW) ? L"open" : L"edit";
590         bool success = reinterpret_cast<intptr_t>(ShellExecuteW(NULL, action,
591                         reinterpret_cast<wchar_t const *>(wname.utf16()),
592                         NULL, NULL, 1)) > 32;
593
594         if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
595                 setEnv("TEXINPUTS", oldtexinputs);
596                 setEnv("BIBINPUTS", oldbibinputs);
597                 setEnv("BSTINPUTS", oldbstinputs);
598                 setEnv("TEXFONTS", oldtexfonts);
599         }
600         return success;
601 }
602
603
604 string real_path(string const & path)
605 {
606         // See http://msdn.microsoft.com/en-us/library/aa366789(VS.85).aspx
607         QString const qpath = get_long_path(toqstr(path));
608         HANDLE hpath = CreateFileW((wchar_t *) qpath.utf16(), GENERIC_READ,
609                                 FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
610
611         if (hpath == INVALID_HANDLE_VALUE) {
612                 // The file cannot be accessed.
613                 return path;
614         }
615
616         // Get the file size.
617         DWORD size_hi = 0;
618         DWORD size_lo = GetFileSize(hpath, &size_hi);
619
620         if (size_lo == 0 && size_hi == 0) {
621                 // A zero-length file cannot be mapped.
622                 CloseHandle(hpath);
623                 return path;
624         }
625
626         // Create a file mapping object.
627         HANDLE hmap = CreateFileMapping(hpath, NULL, PAGE_READONLY, 0, 1, NULL);
628
629         if (!hmap) {
630                 CloseHandle(hpath);
631                 return path;
632         }
633
634         // Create a file mapping to get the file name.
635         void * pmem = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 1);
636
637         if (!pmem) {
638                 CloseHandle(hmap);
639                 CloseHandle(hpath);
640                 return path;
641         }
642
643         TCHAR realpath[MAX_PATH + 1];
644
645         if (!GetMappedFileName(GetCurrentProcess(), pmem, realpath, MAX_PATH)) {
646                 UnmapViewOfFile(pmem);
647                 CloseHandle(hmap);
648                 CloseHandle(hpath);
649                 return path;
650         }
651
652         // Translate device name to UNC prefix or drive letters.
653         TCHAR tmpbuf[MAX_PATH] = TEXT("\\Device\\Mup\\");
654         UINT namelen = _tcslen(tmpbuf);
655         if (_tcsnicmp(realpath, tmpbuf, namelen) == 0) {
656                 // UNC path
657                 _snprintf(tmpbuf, MAX_PATH, "\\\\%s", realpath + namelen);
658                 strncpy(realpath, tmpbuf, MAX_PATH);
659                 realpath[MAX_PATH] = '\0';
660         } else if (GetLogicalDriveStrings(MAX_PATH - 1, tmpbuf)) {
661                 // Check whether device name corresponds to some local drive.
662                 TCHAR name[MAX_PATH];
663                 TCHAR drive[3] = TEXT(" :");
664                 bool found = false;
665                 TCHAR * p = tmpbuf;
666                 do {
667                         // Copy the drive letter to the template string
668                         drive[0] = *p;
669                         // Look up each device name
670                         if (QueryDosDevice(drive, name, MAX_PATH)) {
671                                 namelen = _tcslen(name);
672                                 if (namelen < MAX_PATH) {
673                                         found = _tcsnicmp(realpath, name, namelen) == 0;
674                                         if (found) {
675                                                 // Repl. device spec with drive
676                                                 TCHAR tempfile[MAX_PATH];
677                                                 _snprintf(tempfile,
678                                                         MAX_PATH,
679                                                         "%s%s",
680                                                         drive,
681                                                         realpath + namelen);
682                                                 strncpy(realpath,
683                                                         tempfile,
684                                                         MAX_PATH);
685                                                 realpath[MAX_PATH] = '\0';
686                                         }
687                                 }
688                         }
689                         // Advance p to the next NULL character.
690                         while (*p++) ;
691                 } while (!found && *p);
692         }
693         UnmapViewOfFile(pmem);
694         CloseHandle(hmap);
695         CloseHandle(hpath);
696         string const retpath = subst(string(realpath), '\\', '/');
697         return FileName::fromFilesystemEncoding(retpath).absFileName();
698 }
699
700 } // namespace os
701 } // namespace support
702 } // namespace lyx