x1nick Posted July 31, 2009 Share Posted July 31, 2009 This is just something I would like to integrate into my template system im building, but don't know how possible it is. All I want to be able to do is highlight html code within a text area, and have it automatically highlight as writing the code. Quote Link to comment https://forums.phpfreaks.com/topic/168317-solved-html-syntax-highlighting/ Share on other sites More sharing options...
Mardoxx Posted August 1, 2009 Share Posted August 1, 2009 find a java syntax highlighter, then on your text box set it so onkeyup calls the function to check the syntax of the textbox Quote Link to comment https://forums.phpfreaks.com/topic/168317-solved-html-syntax-highlighting/#findComment-888384 Share on other sites More sharing options...
x1nick Posted August 2, 2009 Author Share Posted August 2, 2009 Found the perfect solution to my problem. http://marijn.haverbeke.nl/codemirror/ Now my problem is that I don't know how to insert my {tpl} var's into the textarea. I guess the codemirror function... this.mirror.insertIntoLine (tpltextarea, this.mirror.cursorPosition(this.mirror.firstLine()), 'text'); Would do the job, I just not too sure how the position works The above line of code puts it into the text area, but not where is selected, just at the end of the textarea. Quote Link to comment https://forums.phpfreaks.com/topic/168317-solved-html-syntax-highlighting/#findComment-889016 Share on other sites More sharing options...
Mardoxx Posted August 3, 2009 Share Posted August 3, 2009 right click, view source: http://marijn.haverbeke.nl/codemirror/jstest.html btw, it's the function mirrorframe which creates the "ugly buttons" from mirrorframe.js (so that can just be ignored) Quote Link to comment https://forums.phpfreaks.com/topic/168317-solved-html-syntax-highlighting/#findComment-889501 Share on other sites More sharing options...
x1nick Posted August 8, 2009 Author Share Posted August 8, 2009 Hmm Think I have solved the problem to what I posted before. Just used self.mirror.replaceSelection(myvar) Now the next problem, I want to incorporate some form of ajax save so it allows for quick easy saving of the files being edited. Problem with this is codemirror replaces the id tag of the textarea so I can't use it with ajax. So tried incorporating it into the mirrorframe file. Would have though the function getCode is what I need to use. So tried this and it just returns undefined. Most likely there is a simple fix for this. but for now im stuck Quote Link to comment https://forums.phpfreaks.com/topic/168317-solved-html-syntax-highlighting/#findComment-893765 Share on other sites More sharing options...
x1nick Posted August 8, 2009 Author Share Posted August 8, 2009 Never mind self.mirror.getCode(); is what I should be using Quote Link to comment https://forums.phpfreaks.com/topic/168317-solved-html-syntax-highlighting/#findComment-893769 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.