Syntax highlighting in basic editor

First of all. Thanks for finally upgrading the forum software. So far it looks like it works much better than the former version. However I'm not totally happy with the basic text editor.
There is quite a lot of code posted in these forums. Is it possible to have the syntax highlighting button in the basic editor?
It helps a lot on readability, and when this button is hidden away in the advanced editor I'm afraid that a lot of users will not find it.

Don’t have an answer for that. Will check with Jive to see if the features of the Inline RTE are configurable.
Thanks!

Similar Messages

  • HTML editor with syntax highlighting and UTF-8 support

    In an ongoing effort to move our lives into the cloud and into our pockets (and as a part of an article series for a tech blog), me and a friend are trying to completely replace the need for computers with our iPhones.
    In some ways, it is going splendidly (Documents to Go Premium + foldable bluetooth keyboard = all my writing needs as a journalist solved). In others, concessions have to be made (as a practicing musician, my options are a bit limited, but with the help of Xewton Music Studio, Multitrack DAW/NanoStudio, etc, I can at least lay down some basic tracks, create basic MIDI compositions, etc).
    However, there is one area in where we’ve made no headway at all. My friend has the great misfortune of being blessed with logic , and therefore, unlike me, does honest programming and web app designing work. And as far as we know, there is not a single HTML/script editor with more than just the bare, basic functions in the app store.
    What we need is this:
    * Syntax highlighting
    * Support for UTF-8
    A built-in FTP editor would be a nice bonus, but is not essential.
    We found one for the iPad, but when we contacted the company behind the app, they revealed no immediate plans for an iPhone version. (They felt coding on the iPhone was, at best, impractical, but they did concede the fact that if there are indeed users who have that need, the existence of an iOS HTML editor would be justified, and possible lucrative, regardless of their feelings on the matter. On that ground, they promised to examine the possibilities to port their iPad app in the future, but so far, no signs.)
    Does anyone know of such an app? Rest assured your assistance will be mentioned in the article series should you point us in the right direction

    Unfortunately, my friend has offered his iPhone an ultimatum. No syntax highlighting, no computer replacement. It is strange that such as standardized feature has not found its way into any known HTML editor for iOS.
    But FTPOntheGo seems to be a great app in general, so thanks!

  • Best strategy for creating a Code Editor (w/ syntax highlighting) in flash

    I'm looking into creating a javascript code editor in flash. I would light to include syntax highlighting and am eliciting suggestings on how best to approach it.
    Here are my thoughts so far:
    I don't see anything pre-built, so I'll have to do it myself, am I wrong here?
    I have seen as3syntaxhighlihgt which will take code and turn it into a highlighted HTML file, but not sure whether or not I could find a way to combine that with a text editor that could support html???
    Thanks for any input that can help guide me.
    David

    After more research I've answered this one myself. For anyone else comming across this thread here is what I found:
    as3syntaxhighlight is a good option for code highlighting in flash, see the demo at:
    http://anirudhs.chaosnet.org/blog/2009.01.12.html
    It embeds very easily and quickly.
    Other options exist for editors built in JS that could potentially be ported:
    http://en.wikipedia.org/wiki/Comparison_of_Javascript-based_source_code_editors

  • An editor with syntax highlight

    How to do that? Use TextField somehow? I do not want HTMLEditor, as it has to be a plain text.

    What kind of syntax highlighting do you want to achieve?
    After the text has been edited and syntax highlighted how to you plan to convert it to plain text without losing the syntax highlighting?

  • Syntax Highlighting w/ Swing Text Package

    I have a question for you that I hope ever so much that you could answer just in the most abstract sense, I will figure out the code from what you have said hopefully. Any relavent parts that you think I should know, please point out.
    My question is, I'm trying to implement Syntax Highlighting for a code editor in Java (yes I know, like everyone else. It would REALLY be helpful if you did an updated Demo of a SyntaxEditor for JDK 1.4 BTW) anyway, I have already implemented Syntax Highlighting by overriding the PlainView and changing its drawLine method to parse the line, find the key words then draw them accordingly. However I cannot get over the sinking feeling that there is a better way to do this in JDK 1.4, I'm not worried about backward compatability. I'm only interested in the "sexiest" way to do this with Java. I started looking into the GlyphView, and that seems more of what I want, it has more control over the text elements and strong drawing abilities, I also noticed the GlyphPainter1 and GlyphPainter2, I tried to extend GlyphPainter2 and use it with my extended GlyphView and just change its paint method to parse the lines, but the class complains about not being public, even though in the source its class definition is "public class GlyphPainer2 extends GlyphView.GlyphPainter" which confused me.
    But at any rate, my basic question is how would YOU, implement Syntax Highlighting (code coloring) if you could do it from scratch with all the facilities of the 1.4 JDK. ALso, should I look into the Java2D API or is this over kill for what I'm doing? I just need a basic code color'er, nothing fancy. But I need the fonts and styles to be able to change, that's all. And international support would be nice.
    The type of answer I'm hoping for is something like "Create a new editor kit and then extend the GlyphView class and override its XYZ method to do your line parsing and then override the ABC method to do the actual painting of the line, this is the best way to do this in java"
    Best wishes,
    -rsk123

    I am searching for text highlighting code in java during 7 days.
    And I also agree with Mr. rsk123 's thought.
    I want to make editor to highlight code using java's general text package.
    But I can't find good source or class to satisfy me.
    Some code run well but it's not use the original java text package.
    Some code was made by using java text package but have a bug and not run pefectly.
    Now, I must choice a code for text highlighting.
    But until now I can't find a free code or comecial code for it.
    Anyway, I summarize my suffing result until now.
    ** I have stuied,
    . About java's text package in Swing Connection site.
    It's useful a little to understand the text package structure.
    (http://java.sun.com/products/jfc/tsc/articles/index.html)
    . How to make own EditorKit in 'Java Swing' book chapter 24.
    I think it's good. But difficult to read.
    (published by O'REILLY. Robert Eckstein)
    ** I have found program and have tested.
    1) JEdit (http://www.jedit.org)
    2) Jext(http://www.jext.org)
    3) Sun's sample using the JavaEditorKit
    (http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/index.html)
    4) Ostermiller's Syntax editor (http://ostermiller.org/syntax/editor.html)
    5) j (http://armedbear-j.sourceforge.net/)
    6) je 1.66 (http://mathsrv.ku-eichstaett.de/MGF/homes/grothmann/je/)
    *** Detail descriptions of the test
    1. May be run well but not use java text package.
    ==> JEdit (http://www.jedit.org), Jext(http://www.jext.org)
    - I executed JEdit and Jext program. it works very well.
    I think It's greate programs.
    - The editor class for these programs are
    org.gjt.sp.jedit.textarea.JEditTextArea class.
    The JEditTextArea class extends JComponent, not java text component.
    - JEditTextArea class started from 'jedit syntax package project'.
    You can download the syntax package if you only use syntax highlighting
    from http://syntax.jedit.org/ .
    - JEdit and Jext use for editor 'jedit syntax package' but have upgrade that
    package their own effort(may be)
    - For me, It's an only product run well without error.
    But unfortunately it's not use java text component.
    So I hesitane to use it.
    Because I should make almost code to support general editor function which
    supported in JTextComponent.
    2. Provided by Sun's developer site.
    ==> JavaEditorKit (http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/index.html)
    - It's made using JEditorPane. Great!!
    And have a good architecture. (I think)
    - But It use Scanner class which located in tools.jar package and
    have a bug which not supporting well comment syntax /* */.
    (Refer to http://developer.java.sun.com/developer/bugParade/bugs/4323090.html)
    Futhermore it display terrible exception message when typed "/*" string
    in the end position of java file. (I tested it)
    - I heard in the forum, someone made the own scanner class.
    (http://forum.java.sun.com/thread.jsp?thread=120564&forum=57&message=316083)
    He said,(he = rofshi)
    I wrote for my purposes a scanner based on the StreamTokenizer
    cl*** and set a corresponding object in the JavaView cl*** of
    the JavaKitTest.
    Then I placed the method of my Scanner cl*** that parses the
    given string and paints tokens in the method drawUnselected
    Text (instead of previous code).
    Of course, I erased all of the previous code related to the
    java Scanner.
    - For me, I like this style code and want to use it.
    But Scanner class have some bug and I can't cure that bug. Terrible...
    3. using JTextPane
    ==> http://ostermiller.org/syntax/editor.html
    - At first it's too slow.
    My computer is PentiumIII 350MHz Ram:256M Windows2000Por
    But when I press pgDown key quickly the display couldn't follow it.
    - And may be not support unicode.
    When I typed international code, exceptions displayed.
    (too much exceptios. may be caused repeating by thread.)
    (ArrayIndexOutOfBoundsException in JavaLexer.java 1022 ?)
    - For me, supporting international code is essential.
    So I can't use it.
    4. Do work well. But it use not understandable code for me.
    (not use general java text package)
    1)http://armedbear-j.sourceforge.net/
    2)http://www.rene-grothmann.de
    *** Finally, I have plan to make my own code using Mr rsk123's idea.
    (using GlyphView in jdk1.3 or jdk1.4)
    *** If you have a good information for text highliting of free code or
    comecial code pleas notify me.
    My address is [email protected]

  • Syntax highlighting, autotabbing in Eclipse?

    Pardon, is there a way to make Eclipse do syntax highlighting and autoindentation a la Vi? I need to use Eclipse because I've got homework involving Java, and features beyond those of a basic text editor could come in handy, methinks.
    (I know the options should be in some obvious location, but I've managed to miss them somehow... :? )

    Er, it does that automatically from a default setup.
    Are you saying that you have no highlighting at all?
    How did you install Eclipse, via pacman or download it yourself from the website? I ask because a couple of years ago when Eclipse was starting to become popular, I downloaded the Eclipse platform, only to find that I got the base system, without any Java IDE features. You see, the language support is in the form of additional plugins. That's why Eclipse can in fact be a Java, Python or C++ IDE, etc, providing someone has written the plugings to make it so.
    Nowadays, the default download (Eclipse SDK) is bundled with the Java dev stuff. For me, it has always worked fine, out of the box. No need to enable highlighting or indenting.

  • Different Styles in PlainView - Syntax Highlighting?

    Hi,
    I've managed to extend PlainView and looking at old JEdit code I have the syntax highlighting working for the most part. However, at certain times while typing the cursor starts to get way ahead of the text it's typing. And as I backspace on the line the cursor eventually gets closer to the character the closer it gets to the start of the line.
    I'm overridding the "drawUnselectedText()" method in PlainView to do the coloring.
    Here's the code, you can see the call to SyntaxUtilities.paintSyntaxLine() which is JEdit's class to do the drawing.
             * Renders the given range in the model as normal unselected text. This
             * is implemented to paint colors based upon the token-to-color
             * translations. To reduce the number of calls to the Graphics object,
             * text is batched up until a color change is detected or the entire
             * requested range has been reached.
             * @param g
             *            the graphics context
             * @param x
             *            the starting X coordinate
             * @param y
             *            the starting Y coordinate
             * @param p0
             *            the beginning position in the model
             * @param p1
             *            the ending position in the model
             * @returns the location of the end of the range
             * @exception BadLocationException
             *                if the range is invalid
            protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException {
                System.out.println("p0: " + p0 + " p1: " + p1 + " x: " + x + " y: " + y);
                // Get the start of the element
                int lineIndex = doc.getDefaultRootElement().getElementIndex(p0);
                // Get the element for the line
                Element elem = doc.getDefaultRootElement().getElement(lineIndex);
                System.out.println("lineIndex: " + lineIndex + " elemStartIDX: " + elem.getStartOffset() + " elemEndIDX: " + elem.getEndOffset());
                // Get the line text
                doc.getText(p0, p1 - p0, currentLineText);
                // If highlighting, mark the tokens
                if (marker != null) {
                    Token t = marker.markTokens(currentLineText, lineIndex);
                    x = SyntaxUtilities.paintSyntaxLine(currentLineText, t, styles, this, g, x, y, p0, p1);
                    System.out.println("Painted line at: " + x);
                } else {
                    // No highlighting requested, draw normal text
                    Font defaultFont = g.getFont();
                    Color defaultColor = styles[0].getColor(); // Default color of text
                    g.setFont(defaultFont);
                    g.setColor(defaultColor);
                    x = Utilities.drawTabbedText(currentLineText, x, y, g, this, p0);
                // Set the last line processed
                lastLine  = lineIndex;
                return x;
    Here is the code from the paintSyntaxLine() method:
         * Paints the specified line onto the graphics context. Note that this
         * method munges the offset and count values of the segment.
         * @param line
         *            The line segment
         * @param tokens
         *            The token list for the line
         * @param styles
         *            The syntax style list
         * @param expander
         *            The tab expander used to determine tab stops. May be null
         * @param gfx
         *            The graphics context
         * @param x
         *            The x co-ordinate
         * @param y
         *            The y co-ordinate
         * @return The x co-ordinate, plus the width of the painted string
        public static int paintSyntaxLine(Segment line, Token tokens, SyntaxStyle[] styles, TabExpander expander, Graphics gfx, int x, int y, int p0, int p1) {
            Font defaultFont = gfx.getFont();
            Color defaultColor = Color.black;
            FontMetrics fm = gfx.getFontMetrics(defaultFont);
            int offset = 0;
            while (tokens != null && tokens.id != Token.END) {
                int length = tokens.length;
                if (tokens.id == Token.NULL) {
                    if (!defaultColor.equals(gfx.getColor()))
                        gfx.setColor(defaultColor);
                    if (!defaultFont.equals(gfx.getFont()))
                        gfx.setFont(defaultFont);
                } else {
                    styles[tokens.id].setGraphicsFlags(gfx, defaultFont);
    //                fm = gfx.getFontMetrics();//[tokens.id].getStyledFont(defaultFont);
    //                FontMetrics dfm = Toolkit.getDefaultToolkit().getFontMetrics(defaultFont);
    //                System.out.println("Font Info: CharWidth[" + fm.charWidth(line.array[p1])+"], Max Advance[" + fm.getMaxAdvance()+"]");
    //                System.out.println("Default Font Info: CharWidth[" + dfm.charWidth(line.array[p1])+"], DMax Advance[" + dfm.getMaxAdvance()+"]");
    ////                x = fm.charsWidth(line.array, p0, length);
                line.count = length;
                x = Utilities.drawTabbedText(line, x, y, gfx, expander, p0);
                line.offset += length;
                offset += length;
                tokens = tokens.next;
            return x;
    I'm not sure what the problem is..i thought it might be an issue with the View and drawing multiple font styles. Since plain view only deals with a single font color and size. I tried using LabelView but that seems to need a StyledDocument and I had problems when I tried to use DefaultStyledDocument for my syntaxdocument. I was getting strange offset issues when using the Segment class.
    Here's what I posted: http://forum.java.sun.com/thread.jspa?threadID=780801
    I am using PlainDocument because that seemed to be what everyone was using for a syntax editor..since the structure of the document in a Plain Document is less complex.
    I orginally started out using the setCharacterAttributes() method on the DefaultStyledDocument and letting the views draw the text. That all seemed to work except for the "segment offset" issue. And I wasn't sure where the best spot to get the document to redraw subsequent lines in the case of changing a multiline comment, etc.
    So, everything I read about others attempts for syntax highlighters seems to use either StyledEditorKit with a fixed language set with custom parsing and using the setCharacterAttributes method. Or they use the plaindocument approach with a custom view..(which no one seems to share the source) or the project just simply uses the JEditTextArea directly (which we can't do in our product).
    We don't need multiple fonts per-line.. The document will always use one font face (Arial, Helvetica, etc) but may use different styles per word (bold, italic, etc).
    I thought I'd need to use FontMetrics to get the size of the font and such. But there didn't seem to be a difference in measurements based on the style of the font. (i.,e A bold font has the same charWidth('m') size as a regular style.
    At least that's what my test program showed..
    The other thing I noticed is that when the document is successfully colored and I use the mouse to select a region of text, the style of the text reverts back to normal. I'm sure that's because I only override the drawUnselectedText() method.
    Any ideas? Is there anyone who has successfully done this?
    Thanks,
    - Tim

    I just tried using a proportional font in my editor, and now I'm seeing your runaway-caret problem. Specifically, the caret remains in sync with the text as long as no bold characters are encountered, but it gets noticeably farther out of whack with each bold character it passes. I suspect that, when you measured the charWidth, your FontMetrics object wasn't really based on a bold font, because bold versions of proportional fonts are larger. And of course, the model/view conversion methods assume that the same style of the same font is used throughout the document. I've never had to deal with that problem, since I've always used monospaced fonts by preference, and bold versions of monospaced fonts really are the same size as the non-bold versions. I suggest you do the same, because getting this to work with proportional fonts look like a major hassle.

  • Syntax highlighted program code in keynote?

    Is there any easy way insert programming code (in my case Ruby code) into a slide so it shows up with syntax highlighting and formating suitable for the code?
    I.E. so it looks like the highlighted code in Textmate or other gui editors?

    TextWrangler (and thus presumably BBEdit) do preserve their syntax colouring when PDFed, as does Taco HTML Edit. My guess is that this is capability is an app-by-app feature.
    If you were desperate for a PDF output to Keynote, you could always copy the text from Textmate and paste it into the freeware TextWrangler. You would likely have to adjust the default syntax colouring to match Textmate, but that would be relatively straightforward.

  • Syntax highlighting not working on PL/SQL developer tool

    Hello,
    Syntax highlighting is not working on PL/SQL developer tool using the beautifier. When I go set Syntax highlighting parameters (from  EDIT>PL/SQL Developer Beautifier Options > User Interface> Editor> Syntax Highlighting ) and click apply, the changes are not reflected in SQL code in the SQL window. Other feautures in the beautifier such as Fonts, Window types are working fine.
    Please help me with this issue.
    Thanks!!
    Shreejit

    As this is not an Oracle related question (let alone Oracle SQL or PL/SQL), and as you've been given a link to the relevant website... I'll now lock this thread.

  • XML Syntax Highlighting

    Hi, I need help with XML Syntax Highlighting. I try to create simple XML editor, but I have probleblems with Syntax Highlighting.
    Is there anyone who can help me?

    Here is personal recommendation, this 3rd party syntax highlight component works quite well for many JTextComponents
    Check out: http://ostermiller.org/syntax/
    ICE

  • XML Syntax highlighting (again :)

    Hi there,
    I know, that there have been quite a view posts about this topics, but as far as I see, there has been no solution to this.
    So I wanted to ask if someone has implemented a XML Syntax highlighting or knows where to get a tutorial from to accomplish so (inheriting from DefaultStyledDocument...?)
    Sincerely
    Charly

    Hi!
    I have the same need: an XML Syntax Highlighting (coloring).
    I don't need an XML editor, I have a JTextPane that shows XML code and I would like it to be done with a syntax coloring.
    If you have a solution I will really appreciate!
    Thanks
    Gio :-)

  • How do I enable syntax highlighting for jspf files on Dreamweaver CS6 on Windows?

    I followed the instructions (which I modified for CS6) in this posting: http://blog.metameister.com/blog/2011/04/08/open-new-file-types-and-add-syntax-highlightin g-in-dreamweaver-cs5-on-window…
    but it did not work for CS6.
    How do I enable syntax highlighting for jspf files on Dreamweaver CS6 on Windows 7?
    cheers
    Marvin in Edmonton

    Ok, I figured it out after hunting for a few hours.
    Step 1. Add the File Type
    In Dreamweaver’s toolbar:
    Select Edit > Preferences; 
    under File Types / Editors, add .jspf to the line “Open in Code View:”.
    Step 2. Extensions.txt
    Add file type .jspf to the Extensions.txt files. There are two of these files:
    C:\Users\[username]\AppData\Roaming\Adobe\Dreamweaver CS6\en_US\Configuration
    C:\Program Files (x86)\Adobe\Adobe Dreamweaver CS6\configuration
    Step 3. MMDocumentTypes.xml
    Add jspf to the MMDocumentTypes.xml files. Open this file in Notepad or Text Editor. Do not modify the Dreamweaver configuration files within Dreamweaver.
    There are three MMDocumentTypes.xml files to be modified: 
    C:\Program Files (x86)\Adobe\Adobe Dreamweaver CS6\configuration\DocumentTypes
    C:\Users\mhaagsma\AppData\Roaming\Adobe\Dreamweaver CS6\en_US\Configuration
    C:\Users\mhaagsma\AppData\Roaming\Adobe\Dreamweaver CS6\en_US\Configuration\DocumentTypes\
    Step 4. Restart Dreamweaver
    Hopefully the file type will now be recognized and appear with syntax highlighting.

  • Syntax Highlighting for MATRIXx MathScript and TPL

    There have been some questions about text editors for MATRIXx, so I wanted to let everyone know about an application note that we just posted. It describes how to configure a syntax highlighter for use with MathScript and Template Programming Language (TPL). There is also an example of how Crimson Editor can be configured. I choose Crimson Editor because it was free, but the same thing can be done in other syntax highlighters. Using a syntax highlighter makes MATRIXx code a lot easier to read.
    http://zone.ni.com/devzone/conceptd.nsf/webmain/C43375149CB01C3186256E530081EAA5
    While I am at it, I am going to point out some other resources. The application note is located on Developer Zone section of our website, where
    you can find other MATRIXx examples and tutorials:
    http://zone.ni.com/devzone/devzone.nsf/webcategories/A92DB8BA2DE149F486256CBC00655A0C?opendocument
    If you have code or examples that you want to share with other users you can submit the example to the Example Code Library:
    http://www.ni.com/devzone/dev_exchange/ex_search.htm
    Suggestions and feedback can be submitted from Product Feedback section of Contact NI:
    http://sine.ni.com/apps/we/nicc.call_me?p_action=country&p_lang_id=US
    And of course the main MATRIXx page is:
    http://www.ni.com/matrixx
    Carl L
    National Instruments

    I found another editor with syntax highlighting capabilities for MATRIXx. The editor is VIM which is based on the Unix VI editor, and is available on both Solaris and Windows.
    www.vim.org
    Carl L
    National Instruments
    www.ni.com/matrixx

  • JSP Syntax Highlighting

    Does anyone know how to configure Syntax highlighting for JSP's in JDeveloper v3.2?
    Thanks
    Mark

    You need a plugin which supports JSP.
    MyEclipse does (along with a lot of other stuff)
    Lomboz also provides a jsp editor
    You can find a whole lot of eclipse plugins at
    http://www.eclipseplugincentral.com/
    http://eclipse-plugins.2y.net/eclipse/index.jsp
    Cheers,
    evnafets

  • Syntax Highlighting and Undo Problem

    Hello Guys. I am working ona very simple type of Java Code Editor with syntax highlighting feature. It works fine as far as the syntax highlighting, cut, copy, paste etc are concerned but when I added Undo, Redo feature, it was not working as Undo Redo should. The UndoManager first removes the text attributes and finally the main Undo job. For example if I paste word public , the UndoManager will first remove the attributes and after about third or fouth click on the Undo button removes the pasted word.
    Please Help.

    Here's the complete demo code.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import javax.swing.text.rtf.*;
    import javax.swing.undo.*;
    class ColorTextInTextPane extends JFrame implements UndoableEditListener
         private Hashtable keywords,impclasses;
         JEditorPane edit;
         UndoManager undo;
         JButton undoIt, redoIt;
         JPanel southButtonPanel;
         MyDocument doc = new MyDocument();
         public ColorTextInTextPane()
              super("ColorTextInTextPane");
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              edit = new JEditorPane();
              edit.setEditorKit(new StyledEditorKit());
              edit.setEditable(true);
              doc.addUndoableEditListener(this);
              edit.setDocument(doc);
              JScrollPane scroll=new JScrollPane(edit);
              undo = new UndoManager();
              undoIt = new JButton("Undo");
              undoIt.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent ae)
                    undoAction(ae);
              redoIt = new JButton("Redo");
              redoIt.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent ae)
                    redoAction(ae);
              southButtonPanel = new JPanel();
              southButtonPanel.add(undoIt);
              southButtonPanel.add(redoIt);
              getContentPane().add(scroll);
              getContentPane().add(southButtonPanel, BorderLayout.SOUTH);
              setSize(300,300);
              setVisible(true);
              Object dummyObject = new Object();
              keywords = new Hashtable();
              keywords.put( "abstract", dummyObject );
              keywords.put( "boolean", dummyObject );
              keywords.put( "break", dummyObject );
              keywords.put( "byte", dummyObject );
              keywords.put( "byvalue", dummyObject );
              keywords.put( "case", dummyObject );
              keywords.put( "cast", dummyObject );
              keywords.put( "catch", dummyObject );
              keywords.put( "char", dummyObject );
              keywords.put( "class", dummyObject );
              keywords.put( "const", dummyObject );
              keywords.put( "continue", dummyObject );
              keywords.put( "default", dummyObject );
              keywords.put( "do", dummyObject );
              keywords.put( "double", dummyObject );
              keywords.put( "else", dummyObject );
              keywords.put( "extends", dummyObject );
              keywords.put( "false", dummyObject );
              keywords.put( "final", dummyObject );
              keywords.put( "finally", dummyObject );
              keywords.put( "float", dummyObject );
              keywords.put( "for", dummyObject );
              keywords.put( "future", dummyObject );
              keywords.put( "generic", dummyObject );
              keywords.put( "goto", dummyObject );
              keywords.put( "if", dummyObject );
              keywords.put( "implements", dummyObject );
              keywords.put( "import", dummyObject );
              keywords.put( "inner", dummyObject );
              keywords.put( "instanceof", dummyObject );
              keywords.put( "int", dummyObject );
              keywords.put( "interface", dummyObject );
              keywords.put( "long", dummyObject );
              keywords.put( "native", dummyObject );
              keywords.put( "new", dummyObject );
              keywords.put( "null", dummyObject );
              keywords.put( "operator", dummyObject );
              keywords.put( "outer", dummyObject );
              keywords.put( "package", dummyObject );
              keywords.put( "private", dummyObject );
              keywords.put( "protected", dummyObject );
              keywords.put( "public", dummyObject );
              keywords.put( "rest", dummyObject );
              keywords.put( "return", dummyObject );
              keywords.put( "short", dummyObject );
              keywords.put( "static", dummyObject );
              keywords.put( "super", dummyObject );
              keywords.put( "switch", dummyObject );
              keywords.put( "synchronized", dummyObject );
              keywords.put( "this", dummyObject );
              keywords.put( "throw", dummyObject );
              keywords.put( "throws", dummyObject );
              keywords.put( "transient", dummyObject );
              keywords.put( "true", dummyObject );
              keywords.put( "try", dummyObject );
              keywords.put( "var", dummyObject );
              keywords.put( "void", dummyObject );
              keywords.put( "volatile", dummyObject );
              keywords.put( "while", dummyObject );
              Object dummyObject1 = new Object();
              impclasses = new Hashtable();
              impclasses.put( "JFrame", dummyObject1);
              impclasses.put( "Applet", dummyObject1);
                    impclasses.put( "JApplet", dummyObject1);
                    impclasses.put( "JTextField", dummyObject1);
                    impclasses.put( "JLabel", dummyObject1);
                    impclasses.put( "JPanel", dummyObject1);
                    impclasses.put( "JButton", dummyObject1);
         public void undoableEditHappened(UndoableEditEvent ev) {
        undo.addEdit(ev.getEdit());
        updateMenu();
      void undoAction(ActionEvent e) {
        try {
          if (undo.canUndo())
            undo.undo();
          updateMenu();
        catch (CannotRedoException cre) {
      void redoAction(ActionEvent e)
        try {
          if (undo.canRedo())
            undo.redo();
          updateMenu();
        catch (CannotRedoException cre) {
      public void updateMenu()
        undoIt.setEnabled(undo.canUndo());
        redoIt.setEnabled(undo.canRedo());
         public static void main(String a[])
              new ColorTextInTextPane();
         class MyDocument extends DefaultStyledDocument
              DefaultStyledDocument doc;
              MutableAttributeSet normal;
              MutableAttributeSet keyword;
              MutableAttributeSet comment;
              MutableAttributeSet quote;
              MutableAttributeSet impclasses1;
              public MyDocument()
                   doc = this;
                   putProperty( DefaultEditorKit.EndOfLineStringProperty, "\n" );
                   normal = new SimpleAttributeSet();
                   StyleConstants.setForeground(normal, Color.black);
                   comment = new SimpleAttributeSet();
                   StyleConstants.setForeground(comment, Color.green);
                   StyleConstants.setItalic(comment, true);
                   keyword = new SimpleAttributeSet();
                   StyleConstants.setForeground(keyword, Color.blue);
                   StyleConstants.setBold(keyword, true);
                   quote = new SimpleAttributeSet();
                   StyleConstants.setForeground(quote, Color.red);
                   StyleConstants.setBold(quote, true);
                   impclasses1 = new SimpleAttributeSet();
                   StyleConstants.setForeground(impclasses1, Color.magenta);
                   StyleConstants.setBold(impclasses1, true);
              public void insertString(int offset, String str, AttributeSet a) throws BadLocationException
                   super.insertString(offset, str, a);
                   processChangedLines(offset, str.length());
              public void remove(int offset, int length) throws BadLocationException
                   super.remove(offset, length);
                   processChangedLines(offset, 0);
              public void processChangedLines(int offset, int length) throws BadLocationException
                   String content = doc.getText(0, doc.getLength());
                   Element root = doc.getDefaultRootElement();
                   int startLine = root.getElementIndex( offset );
                   int endLine = root.getElementIndex( offset + length );
                   for (int i = startLine; i <= endLine; i++)
                        int startOffset = root.getElement( i ).getStartOffset();
                        int endOffset = root.getElement( i ).getEndOffset();
                        applyHighlighting(content, startOffset, endOffset - 1);
              public void applyHighlighting(String content, int startOffset, int endOffset)
                   throws BadLocationException
                   int index;
                   int lineLength = endOffset - startOffset;
                   int contentLength = content.length();
                   if (endOffset >= contentLength)
                        endOffset = contentLength - 1;
                   //  set normal attributes for the line
                   doc.setCharacterAttributes(startOffset, lineLength, normal, true);
                   //  check for multi line comment
                   String multiLineStartDelimiter = "/*";
                   String multiLineEndDelimiter = "*/";
                   index = content.lastIndexOf( multiLineStartDelimiter, endOffset );
                   if (index > -1)
                        int index2 = content.indexOf( multiLineEndDelimiter, index );
                        if ( (index2 == -1) || (index2 > endOffset) )
                             doc.setCharacterAttributes(index, endOffset - index + 1, comment, false);
                             return;
                        else
                        if (index2 >= startOffset)
                             doc.setCharacterAttributes(index, index2 + 2 - index, comment, false);
                             return;
                   //  check for single line comment
                   String singleLineDelimiter = "//";
                   index = content.indexOf( singleLineDelimiter, startOffset );
                   if ( (index > -1) && (index < endOffset) )
                        doc.setCharacterAttributes(index, endOffset - index + 1, comment, false);
                        endOffset = index - 1;
                   //  check for tokens
                   checkForTokens(content, startOffset, endOffset);
              private void checkForTokens(String content, int startOffset, int endOffset)
                   while (startOffset <= endOffset)
                        //  find the start of a new token
                        while ( isDelimiter( content.substring(startOffset, startOffset + 1) ) )
                             if (startOffset < endOffset)
                                  startOffset++;
                             else
                                  return;
                        if ( isQuoteDelimiter( content.substring(startOffset, startOffset + 1) ) )
                             startOffset = getQuoteToken(content, startOffset, endOffset);
                        else
                             startOffset = getOtherToken(content, startOffset, endOffset);
              private boolean isDelimiter(String character)
                   String operands = ";:{}()[]+-/%<=>!&|^~*";
                 if (Character.isWhitespace( character.charAt(0) ) ||
                      operands.indexOf(character) != -1 )
                      return true;
                 else
                      return false;
              private boolean isQuoteDelimiter(String character)
                   String quoteDelimiters = "\"'";
                   if (quoteDelimiters.indexOf(character) == -1)
                      return false;
                 else
                      return true;
              private boolean isKeyword(String token)
                   Object o = keywords.get( token );
                   return o == null ? false : true;
              private boolean isimpclasses1(String token)
                   Object o = impclasses.get( token );
                   return o == null ? false : true;
              private int getQuoteToken(String content, int startOffset, int endOffset)
                   String quoteDelimiter = content.substring(startOffset, startOffset + 1);
                   String escapedDelimiter = "\\" + quoteDelimiter;
                   int index;
                   int endOfQuote = startOffset;
                   //  skip over the escaped quotes in this quote
                   index = content.indexOf(escapedDelimiter, endOfQuote + 1);
                   while ( (index > -1) && (index < endOffset) )
                        endOfQuote = index + 1;
                        index = content.indexOf(escapedDelimiter, endOfQuote);
                   // now find the matching delimiter
                   index = content.indexOf(quoteDelimiter, endOfQuote + 1);
                   if ( (index == -1) || (index > endOffset) )
                        endOfQuote = endOffset;
                   else
                        endOfQuote = index;
                   doc.setCharacterAttributes(startOffset, endOfQuote - startOffset + 1, quote, false);
                            //String token = content.substring(startOffset, endOfQuote + 1);
                            //System.out.println( "quote: " + token );
                   return endOfQuote + 1;
              private int getOtherToken(String content, int startOffset, int endOffset)
                 int endOfToken = startOffset + 1;
                   while ( endOfToken <= endOffset )
                        if ( isDelimiter( content.substring(endOfToken, endOfToken + 1) ) )
                             break;
                        endOfToken++;
                   String token = content.substring(startOffset, endOfToken);
                            //System.out.println( "found: " + token );
                   if ( isKeyword( token ) )
                        doc.setCharacterAttributes(startOffset, endOfToken - startOffset, keyword, false);
                   if(isimpclasses1 ( token) )
                        doc.setCharacterAttributes(startOffset, endOfToken - startOffset, impclasses1, false);
                   return endOfToken + 1;
    }

Maybe you are looking for

  • External Identity Sources, binding RSA securID to ISE

    Hi all, Say, my topology was using ISE doing VPN inline posture, and bind RSA securID (version 7.1) as external Identity Sources. During  the deployment, in order to let my iPEP node join the Policy Service  Node, for the certificate i using the thir

  • Flash Player 10.3 will not work in Safari on Mac OS X 10.5.8. Please help!

    Mac OS X 10.5.8 Safari 5.0.6 Flash Player 10.3 I'm not sure what the problem is. I could play youtube videos etc fine last time I was on the computer and now they just wont work and say 'plug-in missing'. But when I try to download the latest compati

  • Target Documents G/L Account on the Details Line is not Updated

    Hello, I am trying to promote a Sales Order into a Delivery Note. The Sales Order lines are created using a particular warehouse.  The customer may pick up the items from a different location, so we would promote the Sales Order and modify the wareho

  • Multiple Entries in EditBox with "," Separator

    Hello, We have one Edit Box in Dashboard to enter Employee_Number, users wants to enter multiple Emp_Number with "," separated. Actually users wants to copy the employee_number from the flat files with "," seprator and paste into Editbox, the report

  • Cant install flash 9

    yes i need help ive been trying to download flash player an it keeps getting a pop up after a few min into the download it saying download interution please check your internet connection an try again the screen is plank but there is a box in the top