-
Notifications
You must be signed in to change notification settings - Fork 900
Support editing LaTeX in an external editor #6476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR!
I think both 3. and 4. would be neatly solved by keeping a LatexDialog that would be modal (like the default one) and hence forbid any interaction with the main window. |
Thanks for the feedback! I've addressed your requests. I've split the
I've also written some code that removes a tra 8000 iling newline (which I have confirmed kwrite does add), if any. I haven't been able to get LaTeX running myself as I use Typst instead which doesn't complain about a trailing newline, it would be appreciated if you could give it a test on your LaTeX setup. An option to automatically confirm like you suggested has also been added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It all seems to works as expected. I have a couple of comments/nitpicks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It all looks good and works as well.
I'd be more confortable if someone could test this on Windows before we merged
Thanks! I unfortunately don't have a windows machine to test on. |
That's interesting, it seems like |
Looks like the code used to incorrectly look for |
We open the file in (text) reading mode. From https://en.cppreference.com/w/cpp/io/c/FILE.html#Binary_and_text_modes
|
It all works after applying this patch: --- a/src/util/PathUtil.cpp
+++ b/src/util/PathUtil.cpp
@@ -63,11 +63,10 @@ auto Util::getLongPath(const fs::path& path) -> fs::path { return path; }
auto Util::readString(fs::path const& path, bool showErrorToUser, std::ios_base::openmode openmode)
-> std::optional<std::string> {
try {
- std::string s;
+ std::stringstream buffer;
std::ifstream ifs{path, openmode};
- s.resize(fs::file_size(path));
- ifs.read(s.data(), as_signed(s.size()));
- return {std::move(s)};
+ buffer << ifs.rdbuf();
+ return buffer.str();
} catch (const fs::filesystem_error& e) {
if (showErrorToUser) {
XojMsgBox::showErrorToUser(nullptr, e.what()); |
Thank you! I've applied your patch! |
I tested on MacOS ARM.
|
I'm guessing that TeXShop returns straight away (and its main process has been forked). So, on our end, the GSubprocess returns immediately, so the preview gets updated right after the editor is opened instead of after its termination. I don't see a way to handle this kind of cases (other than running texshop with some kind of no-fork flag, if any is implemented). |
Could it be the |
Unfortunately using the |
Perhaps TeXShop forks off additionally to (note that I have absolutely no experience with MacOS) |
There are no command line options for TeXShop on MacOS. See It also cannot be started via |
I have also tried Texifier. This one can also be run directly through the binary: |
One possible solution could be to switch from "I wait until the app terminates" to "I wait until the file is saved" using a GFileMonitor. |
This poses quite a few questions:
|
7f9438a
to
2fb4282
Compare
This adds support for editing LaTeX in a user-configurable external editor instead of the built-in one (disabled by default).
This also includes a small refactor where LatexController is kept as
shared_ptr
instead of aunique_ptr
because without the dialog (necessarily) around, we would otherwise run into a scenario where the controller is destroyed before we run some callbacks.Closes #6466