Skip to content
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

Beamer frame preview #92

Open
basilgass opened this issue Dec 9, 2019 · 17 comments
Open

Beamer frame preview #92

basilgass opened this issue Dec 9, 2019 · 17 comments
Assignees
Labels
💡 enhancement Improvement to an existing feature

Comments

@basilgass
Copy link

Feature Request

I would like to be able to preview one frame from a beamer presentation, similar to what's done with tikzpreview.

Is your feature request related to a problem? Please describe.

Nothing particular.

Describe the solution you'd like

I would like something similar to tikzpreview. The script should detect the \begin{frame}...\end{frame} tags.
It would then isolate the current frame and display it in a new tab.
As option, I think it would be great to have the choice to activate the "handout" option.

Describe alternatives you've considered

As alternative, I think a more general version of "preview" would be great. For example, when the cursor is in an environnement, he could activate the preview for this environnement. This would be usefull to create table, arrays and have the preview auto update after a a timeout.

Additional context

Nothing particular.

@basilgass basilgass added the ✨ Feature request This would be nice, a new feature label Dec 9, 2019
@tecosaur
Copy link
Owner

tecosaur commented Dec 9, 2019

I happen to have been thinking the same thing myself. I think a general "preview cursor selection" and setting for environments to preview would be a good idea.

Unfortunately, there are a few things currently in the pipeline, so for the moment this will have to be put asside. However if you wanted to see it sooner and help out a bit I'd welcome a PR!

@tecosaur tecosaur added 💡 enhancement Improvement to an existing feature and removed ✨ Feature request This would be nice, a new feature labels Dec 9, 2019
@basilgass
Copy link
Author

So far, I was able to modify the existing files to make it work with a beamer presentation instead of TikzPictures (but certainly have to do some optimization).

What I need to do now is creating and including new files in Latex-utilities. My first attempts weren't successfull... I need to understand a little bit more how the things works. In particular, my new codelense seems to not be detected...

I'll try to work on this in the coming days!

@tecosaur
Copy link
Owner

Lovely! I'm afraid I'm a bit too busy to work on this right now, but if you're willing to get this to the state where you can make a PR that would be marvellous 🎉.

What I can do is try to answer questions, and offer tips 😃

Re: the code lense, I'd try to approach this by modifying providers/tikzcodelense.ts

const startRegex = /\\begin{(?:tikzpicture|\w*tikz\w*)}/
const endRegex = /\\end{(?:tikzpicture|\w*tikz\w*)}/

For actually getting it to work well, I'd look at components/tikzpreview.ts, it shouldn't require too much work, you just need to generalise a few aspects of it.

const tikzPictureStartIndex = stripComments(startLine.text, '%').search(
/\\begin{(?:tikzpicture|\w*tikz\w*)}/

const endRegex = /\\end{(?:tikzpicture|\w*tikz\w*)}/

It would also probably be worth just chucking the whole preamble in, instead of having the tikz-specific stuff currently happening.

private async generatePreamble(fileTikzCollection: IFileTikzCollection, maxParsedLine?: number) {

The other big tweak that I'd consider beneficial is if it could be made to work on any selection, not just specific environments, but consider that a 'stretch' goal 😉

Anyway, best of luck, and I hope this goes well!

@tecosaur
Copy link
Owner

@basilgass how's it going?

@basilgass
Copy link
Author

@tecosaur I'm working on it. Unfortunately, I had too much things to do last week. I'll try to finish this during the next days :)

@tecosaur
Copy link
Owner

I'm just glad to hear you're still on it :)

@tecosaur
Copy link
Owner

tecosaur commented Jan 4, 2020

@basilgass managed to squeeze any more time in for this, or too busy around Christmas? 😜

@basilgass
Copy link
Author

Hi! Christmas is taking a LOT of time :)

I have it working.,, But I'm encountering one or two problems:

  1. What compiler to use ? If the user is using LuaLaTeX or something else, the actual system won't work. I should add a preference so the user can choose a "recipe" for the preview.

  2. Wondering if it wouldn't be easier to set "presentation:0" to all frame execpt currently focused. This way, the user would only need to compile using their recipe. What do you think ?

  3. Another thing is adding a preferences to enable/disable the "handout" feature.

Another question concerning the Codelense technology - I wanted to make the beamer codelense in a different typescript file... But I didn't find the way to add two codelense for the same file type. Maybe I'm missing something...

@tecosaur
Copy link
Owner

tecosaur commented Jan 4, 2020

Hmm. You seem to be taking a different approach to that I would.
Personally I'd less add a second similar tikzpreview.ts, and more generalise the file such that tikzpreview and beamerpreview are simply particular supported cases (and others can be arbitrarily added via user config).

With regards to your specific questions:

  1. I'd just use what the user currently has set as their default recipe, adding another setting seems like unnecessary duplication. The only other thing would be recognising %! TEX-MAGIC comments for building, but LaTeX-workshop does that already, we just need to pull that out of it.
  2. I haven't actually used beamer (yet) myself, so I'm not actually sure what you mean 😅
  3. See (2)

Anyway, I look forward to seeing your work 😃, if you can though it would be really nice to have a solution which doesn't just support beamer and tikz, but any of a list of environments the user can provide,
From memory, the current code should have 80% of what's needed for that.

@basilgass
Copy link
Author

I'm stating it all over again! I will try to make every environnement work with this preview. As soon as I have something to show, I'll let you know 😃

@tecosaur
Copy link
Owner

That sounds great! I'm just happy I'm not doing the work 😝

@basilgass
Copy link
Author

I didn't forgot. I have a working version... Except I'm encountering a problem (I had the same problem with the first version... This was one of the reason that made me restart the work).

First, how it works right now:

  1. I add in the preferences a string list of groups to identify and to display. An option allows to include or not stared items (equation and equation* for example).
  2. The codelense displays correclty, with an index for each groups.
  3. Clicking the "View in tab" is opening a new tab as expected (but it's not as fast as I would).

But... the problem comes with the update. When I modify something, the preview tab should update. Instead, it opens new tabs for each update... I don't know what's happening.

The problem comes from here:
const refreshed = this.extension.workshop.viewer.refreshExistingViewer(tikzPicture.tempFile)

It returns false and, therefore, opens a new tab. I'm still investigating...

@tecosaur
Copy link
Owner

tecosaur commented Feb 4, 2020

It brings me great joy to hear that you are still working with this! Thank you very much for the update.

Unfortunately, I am as lost as you are from your description of the issue. I would love to help, however, for the next few weeks, time is going to be very tight for me.

All I can recommend is making the most of the built-in debugging tools, specifically the ability to pause at the troublesome point and use the console to test slightly different inputs.

Best of luck, and I look forward to seeing this feature in all its glory.

@jsahil730
Copy link

@basilgass @tecosaur has something been discussed on this issue?

@tecosaur
Copy link
Owner

I haven't said anything since. I'm just here for questions or when there's something to be merged :)

@basilgass
Copy link
Author

I tried multiple times to make this wokring correctly. And it was working... except of one thing - the peview was always opening a new tab, I didn't found a solution to refresh the preview tab instead of opening a new one. And since, lots of things happened for me... and I didn't had the time to investigate anymore.

Next thing was... as I developped this, the codelense appears... everywhere ! And it becomes hard to read the LaTeX code. So I'm not sure it's the correct way to do this. Maybe we could find an easier solution ?

@tecosaur
Copy link
Owner

Hmm. Sounds like it's mostly working?
If it is, perhaps consider creating a PR so any other interested people can chip in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 enhancement Improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants