#366 Preview updating automatically.

open
nobody
None
9
2015-11-25
2012-11-26
Anonymous
No

Make the preview updating as something is changed in the window were you write the actual document.

Related

Feature Requests: #1150

Discussion

  • Tim Hoffmann

    Tim Hoffmann - 2012-11-29

    Do you mean the inline preview or the PDF?

    The inline preview already supports this.

    The problem for the PDF is that latex compilation for large documents can take very long (several seconds are not unusual - I've heard of up to hours for very specialized cases). Apart from the delay, permanently updating the PDF means that your CPU will run at 100% all the time.

    Maybe we'll anyway consider this later as an option.

     
  • Benito van der Zander

    I wrote a script to do automatically pdf updates.

    rdiaz tested it and said it works, but causes flickering...

    And you have to replace

    qApp->instance()->processEvents(QEventLoop::ExcludeUserInputEvents);
    

    in buildmanager.cpp by

    qApp->instance()->processEvents(QEventLoop::AllEvents);
    

    or you cannot write anything during that calculation

    The script:

    %SCRIPT
    
    var PDFLATEX = "pdflatex  -synctex=1 -interaction=nonstopmode %.tex";
    var LIVE_PREVIEW_DELAY = 1000 /*ms*/;
    
    var lastBuildTime = 0;
    var running = 0;
    var runningFromHere = false;
    
    function changed(){
    var doc = documentManager.currentDocument;
    if (!doc || doc.fileName == "") return;
    var t = new Date().getTime();
    setTimeout(function(){build(t);}, LIVE_PREVIEW_DELAY);
    }
    
    function build(time){
    if (time < lastBuildTime) return;
    if (running > 0 || runningFromHere) return;
    
    var doc = documentManager.currentDocument;
    if (!doc) return;
    var line = doc.editorView.editor.cursor.lineNumber();
    
    doc.editorView.editor.save();
    runningFromHere = true;
    buildManager.runCommand(PDFLATEX, documentManager.getCompileFileName(), 
    documentManager.getCurrentFileName(), line);
    }
    
    function buildDone(){
    lastBuildTime = new Date().getTime();
    running--;
    runningFromHere = false;
    }
    
    function newEditor(){
    attach(documentManager.currentDocument);
    }
    
    function attach(doc){
    if (!doc) return;
    doc.editorView.editor.textEdited.connect(changed);
    }
    
    app.infoNewFile.connect(newEditor);
    app.infoNewFromTemplate.connect(newEditor);
    app.infoLoadFile.connect(newEditor);
    buildManager.beginRunningCommands.connect(function(){running++;});
    buildManager.endRunningCommands.connect(buildDone);
    registerAsBackgroundScript("livepreview");
    for (var i=0;i<documents.length;i++)
       attach(documents[i]);
    
     
    Last edit: Tim Hoffmann 2017-02-26
  • Etienne

    Etienne - 2013-02-03

    You could probably get something using latexmk and its -pvc command line option. It would event recompile bibtex if needs be. Combined with \includeonly{} and draft mode, your document will be compiled faster.

     

Log in to post a comment.