Menu

Output to pane / LUA

Klopp
2013-11-30
2013-12-12
  • Klopp

    Klopp - 2013-11-30

    Can I print text into output pane (from LUA script)?

     
  • Yevgen Muntyan

    Yevgen Muntyan - 2013-12-03

    No, it doesn't look like you can.

     
  • Klopp

    Klopp - 2013-12-03

    Maybe from python? Current thing:

    filename = doc.get_filename()
    codefile = os.tmpname()
    rc = os.execute(string.format("/usr/bin/perl -c \"%s\" > \"%s\" 2>&1",filename,codefile))
    if rc == 0 then 
      tidyfile = os.tmpname()
      os.execute(string.format("/usr/bin/perltidy -nsak=\"if elsif unless for while\" -pt=0 -i=4 -bl -vt=2 -vtc=2 -boc -st \"%s\" > \"%s\"",filename,tidyfile))
      out = io.open(tidyfile,"r")
      doc.select_all()
      doc.replace_selected_text(out:read("*a"))
      doc.save()
      os.remove(tidyfile)
    else
      out = io.open(codefile,"r")
      err = string.format("Run syntax check!\n\n%s",out:read("*a"))
    --> HERE:
      moo.error_dialog(err)
    end
    os.remove(codefile)
    
     
  • Yevgen Muntyan

    Yevgen Muntyan - 2013-12-03

    No, it looks like output pane is well hidden. Once it has been shown once, you can get it with undocumented window.get_pane("moo-edit-window-output") call; but the function which creates it for the first time is not exposed to scripts. Why do you need output pane in the first place?

    You may be able to do something similar to what you do in code above with a shell script tool: use "Whole document" as input and "Insert into the document" as output. However, I am not sure what happens in case of errors, I am afraid it will just ignore errors: you could work that around by putting the above code into a shell script, and output the document as it is if an error happened. It won't be automatically saved. There is also "Output pane" output kind for shell scripts, if you want it there. All these things are documented in help.

     
  • Klopp

    Klopp - 2013-12-04

    I want:

    1) replace code in edit window if perltidy return no errors
    2) show errors (no perltidy errors, errors of "perl -c") if perl syntax is not OK (in output pane, for browse lines with errors)

    In "shell script" settings this is impossible(?): or output to pane, or in edit window, depending on the result of the running external script.

     
  • Yevgen Muntyan

    Yevgen Muntyan - 2013-12-04

    Right, shell script won't work. It seems you really need internal APIs which aren't exposed currently.

     
  • Klopp

    Klopp - 2013-12-12

    Thanks, it works with lua :)

    P.S. In .97 sources i see code folding, and closing icons for individual tabs... not implemented completely?

     

Log in to post a comment.

MongoDB Logo MongoDB