Use CodeMirror for query editor
Use triggers for menu actions
Make prologEditor.source("") work