CodeMirror-XQuery
CodeMirror-XQuery copied to clipboard
Templates plugin - end template editing mode when user presses Ender or Tab on last var
Hi Angelo,
I think CodeMirror should provide templates and text hover features too.
One thing I want to know about templates is
it jumps between vars perfectly, I just want to change cursor position after last jump:
for (var index = 0; index < array.length; index++) {
}
It jumps to array var, When user presses Enter or Tab it should end template editing and jump to this pos:
for (var index = 0; index < array.length; index++) { | }
Maybe I just missing something.
Many thanks for help.
Best regards, Boyan
In short answer, its because it's not implemented.
Templates hint is managed for any mode with https://github.com/angelozerr/CodeMirror-XQuery/blob/master/codemirror-extension/addon/hint/templates-hint.js
For javascript, templates are managed with https://github.com/angelozerr/CodeMirror-XQuery/blob/master/codemirror-javascript/addon/hint/javascript/javascript-templates.js
The templates syntax is the same than Eclipse templates. For your information, I have not created at hand the javascript-templates.js . I have used the Eclipse Javascript JSDT templates (templates are XML) and develop a Java SAX Handler to transform Eclipse XML templates to CodeMirror JSON Templates (see https://github.com/angelozerr/CodeMirror-Java/blob/master/src/main/java/codemirror/hint/generator/templates/eclipse/EclipseTemplate2JSHandler.java)
That's why the for templates is :
for (var ${index} = 0; ${index} < ${array}.length; ${index}++) {\n\t${line_selection}${cursor}\n}
To manage your case, ${line_selection}${cursor} should be interpreted in the https://github.com/angelozerr/CodeMirror-XQuery/blob/master/codemirror-javascript/addon/hint/javascript/javascript-templates.js
I don't know if it easy to manage that.
Any contribution are welcome!
Regards Angelo
Hi Angelo!
It's good to know that Marijn merged your commit. I think there should be some delay before showing hover(check if user still holds cursor for some time), like many IDEs do, that should be easy implement, first of all I will try to get it to work in HIDE project, then maybe will try to understand your code. Thanks for your hard work and such a detailed answer.
Best regards, Boyan
In the demo http://codemirror-java.opensagres.eu.cloudbees.net/codemirror-javascript/demo/javascript-all.html hover id displayed with 300ms delay with option :
textHover: {delay:300}

Stops on ${cursor}.
http://as3boyan.github.io/
Seems like idents works pretty badly, maybe Haxe mode needs fixes...
Hi Boyan,
Links about your js files in the demo doesn't work. If you have improved my work, I think it should be better that you create a pull request in order to avoid having several github which provides the same features templates hints.
Regards Angelo