private void setupDocumentLayer ( )
    {
        documentPresentationLayer = new DefaultStyledDocument() 
        {
            private static final long serialVersionUID = 1L;
            public void insertString (int offset, String str, AttributeSet a) throws BadLocationException {
                super.insertString(offset, str, a);

                String text = getText(0, getLength());
                int before = Grammer.findLastNonWordChar(text, offset);
                if (before < 0) before = 0;
                int after = Grammer.findFirstNonWordChar(text, offset + str.length());
                int wordL = before, wordR = before;

                while (wordR <= after) {
                    if (wordR == after || String.valueOf(text.charAt(wordR)).matches("\\W")) 
                    {
                        
                        if (text.substring(wordL, wordR).matches("(\\W)*" + Grammer.computationalUnitsRegEx) && "isf" == fileFormat)
                            setCharacterAttributes(wordL, wordR - wordL, Grammer.attr, false);
                        else
                            setCharacterAttributes(wordL, wordR - wordL, Grammer.attrBlack, false);
                        wordL = wordR;
                    }
                    wordR++;
                }
            }

            public void remove (int offs, int len) throws BadLocationException {
                super.remove(offs, len);

                String text = getText(0, getLength());
                int before = Grammer.findLastNonWordChar(text, offs);
                if (before < 0) before = 0;
                int after = Grammer.findFirstNonWordChar(text, offs);

                if (text.substring(before, after).matches("(\\W)*" + Grammer.computationalUnitsRegEx)) {
                    setCharacterAttributes(before, after - before, Grammer.attr, false);
                } else {
                    setCharacterAttributes(before, after - before, Grammer.attrBlack, false);
                }
            }
            
        };
    }