开发者

how can I get my text area to auto format text

开发者 https://www.devze.com 2023-01-29 19:20 出处:网络
I want to know how to make a text area in a browser into a programmers text editor. For anyone that uses textmate -- I basically want it web-based.

I want to know how to make a text area in a browser into a programmers text editor. For anyone that uses textmate -- I basically want it web-based. for anyone that uses notepad++ -- same idea as above.

I know how to make a开发者_开发问答 text area using html. what I dont know is how to tag the text areas. for instance. in notepad++ and textmade, I can insert the <> tags and it will highlight the text blue. How can I achieve this, live, in a browser. I already know how to parse it after the text has been posted. I want it to be parsed while the user is typing it.


EditArea is pretty good.


In addition to EditArea there's CodeMirror and Mozilla's Bespin


EDIT: I misunderstood the question a little. Jump to ORIGINAL ANSWER if you are curious.

EDIT2: My answer is how to provide SYNTAX HIGHLIGHTING (what is specified in the question itself). Highlighting individual characters unrelated to the syntax requires trivial javascript. This is also distinct from 'auto format' which is commonly interpreted to mean 'adjust my indent levels so it all looks good'.

This is a difficult task, but not as impossible as it seems. Once again, TextMate comes to our rescue but in a different fashion.

In TextMate, open the bundle editor and look at the language definition for HTML. Those are regexes that process the document and assign a 'scope' to each piece.

'Simply' parse that language definition format into the various components, and then use the regexes themselves like TextMate does to assign a scope/color. Piece of cake, right? :)

I would personally start with the most lightweight open source rich text editor you can find, then hack it into that. Or ya know, whatever floats your boat.

I hope that gave you some good ideas.

ORIGINAL ANSWER:

For Firefox, you can install the plugin 'It's All Text' from here: https://addons.mozilla.org/en-US/firefox/addon/4125/

It works for me with 3.6.12. Set the path in preferences to TextMate (or whatever), and optionally set a hotkey or adjust the other settings to your liking. Be default, when your cursor is over a Textarea, a small button saying "Edit" will appear and open the contents of the Textarea in your editor. Saving will put the data back into the Textarea.

I hope this helps.


JSMinNpp plugin just for javascript auto-formatting http://sourceforge.net/projects/jsminnpp/

0

精彩评论

暂无评论...
验证码 换一张
取 消