Ignore:
Timestamp:
06/05/08 10:11:18 (16 years ago)
Author:
ra33
Message:

Added DebugFrame action
Added GetCometStats
Lots of bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Text.java

    r80 r86  
    353353        }
    354354
    355         public Point getEndLinePosition(int mouseY) {
     355        public Point getEndPosition(int mouseY) {
    356356                return getEdgePosition(getLinePosition(mouseY), false);
    357357        }
    358358
    359         public Point getStartLinePosition(int mouseY) {
     359        public Point getStartPosition(int mouseY) {
    360360                return getEdgePosition(getLinePosition(mouseY), true);
    361361        }
     
    363363        public Point getEndParagraphPosition() {
    364364                return getEdgePosition(_textLayouts.size() - 1, false);
     365        }
     366       
     367        public Point getStartParagraphPosition() {
     368                return getEdgePosition(0, true);
    365369        }
    366370
     
    520524                                // Text length greater than 1 signals a backwards tab
    521525                                if (text.length() > 1) {
    522 //                                      Find the first non space char to see if its a bullet
     526                                        // Find the first non space char to see if its a bullet
    523527                                        int index = 0;
    524528                                        for (index = 0; index < _text.length(); index++) {
     
    527531                                        }
    528532                                        // Check if there is a space after the bullet
    529                                         if (index < _text.length() - 1 && _text.charAt(index + 1) == ' ') {
     533                                        if (index < _text.length() - 1
     534                                                        && _text.charAt(index + 1) == ' ') {
    530535                                                // Change the bullet
    531                                                 _text.setCharAt(index, getPreviousBullet(_text.charAt(index)));
     536                                                _text.setCharAt(index, getPreviousBullet(_text
     537                                                                .charAt(index)));
    532538                                        }
    533539                                        // Remove the spacing at the start
    534540                                        for (int i = 0; i < TAB_STRING.length(); i++) {
    535                                                 if (_text.length() > 0 && Character.isSpaceChar(_text.charAt(0))){
     541                                                if (_text.length() > 0
     542                                                                && Character.isSpaceChar(_text.charAt(0))) {
    536543                                                        deleteChar(0, false);
    537544                                                        pos--;
     
    612619                // check for home or end keys
    613620                if (direction == HOME)
    614                         return getStartLinePosition(mouseY);
     621                        return getStartParagraphPosition();
    615622
    616623                if (direction == END)
    617                         return getEndLinePosition(mouseY);
     624                        return getEndParagraphPosition();
    618625
    619626                TextHitInfo hit;
     
    640647
    641648                        if (direction == LEFT) {
    642                                 if (hit.getInsertionIndex() > 0)
     649                                if (hit.getInsertionIndex() > 0) {
    643650                                        hit = _textLayouts.get(line).getNextLeftHit(hit);
    644 
    645                                 if (line > 0
    646                                                 && _text.charAt(hit.getInsertionIndex()
    647                                                                 + _lineOffsets.get(line)) == '\n') {
     651                                        //This takes care of the case where the user has put a hard line break in
     652                                        if (line > 0
     653                                                        && _text.charAt(hit.getInsertionIndex()
     654                                                                        + _lineOffsets.get(line)) == '\n') {
     655                                                line--;
     656                                                hit = _textLayouts.get(line).getNextRightHit(
     657                                                                _textLayouts.get(line).getCharacterCount() - 1);
     658                                        }
     659                                        //This takes care of soft line breaks.
     660                                } else if (line > 0) {
    648661                                        line--;
    649662                                        hit = _textLayouts.get(line).getNextRightHit(
    650663                                                        _textLayouts.get(line).getCharacterCount() - 1);
     664                                        while (hit.getCharIndex() > 0
     665                                                        && _text.charAt(_lineOffsets.get(line)
     666                                                                        + hit.getCharIndex()- 1) == ' '){
     667                                                hit = _textLayouts.get(line).getNextLeftHit(hit);
     668                                        }
    651669                                }
    652670                        } else if (direction == RIGHT) {
     
    12321250                // the background is only cleared if required
    12331251                if (getBackgroundColor() != null) {
    1234                         g.setColor(getBackgroundColor());
     1252                        Color bgc = getBackgroundColor();
     1253                        if (_alpha > 0)
     1254                                bgc = new Color(bgc.getRed(), bgc.getGreen(), bgc.getBlue(),
     1255                                                _alpha);
     1256                        g.setColor(bgc);
    12351257                        g.fill(getPolygon());
    12361258                }
Note: See TracChangeset for help on using the changeset viewer.