[brailleblaster] push by brandon....@xxxxxxxxx - Fixed bug in skipping read only sections that appear first in a docume... on 2014-07-21 19:32 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Mon, 21 Jul 2014 19:32:46 +0000

Revision: 4eace7096a7d
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Mon Jul 21 19:30:53 2014 UTC
Log: Fixed bug in skipping read only sections that appear first in a document
http://code.google.com/p/brailleblaster/source/detail?r=4eace7096a7d

Modified:
 /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java
 /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java Mon Jul 21 15:35:17 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java Mon Jul 21 19:30:53 2014 UTC
@@ -165,9 +165,9 @@
                                                if(e.caretOffset >= currentEnd || 
e.caretOffset < currentStart){
                                                        setCurrent();
if(currentElement instanceof PageMapElement || currentElement instanceof BrlOnlyMapElement){ - if(nextStart != -1 && currentChar == SWT.ARROW_DOWN || currentChar == SWT.ARROW_RIGHT) + if((nextStart != -1 && (currentChar == SWT.ARROW_DOWN || currentChar == SWT.ARROW_RIGHT)) || (previousEnd == -1 && nextStart != -1 && (currentChar == SWT.ARROW_LEFT || currentChar == SWT.ARROW_UP)))
                                                                        
nextValidPosition();
- else if(previousEnd != -1 && currentChar == SWT.ARROW_LEFT || currentChar == SWT.ARROW_UP) + else if((previousEnd != -1 && (currentChar == SWT.ARROW_LEFT || currentChar == SWT.ARROW_UP)) || (nextStart == -1 && previousEnd != -1 && (currentChar == SWT.ARROW_DOWN || currentChar == SWT.ARROW_RIGHT)))
                                                                        
previousValidPosition();
                                                        }

@@ -218,36 +218,55 @@

        private void previousValidPosition(){
TextMapElement t = manager.getElementInBrailleRange(view.getCaretOffset());
-               int index= manager.indexOf(t);
- while(((t.brailleList.getFirst().start != 0 && manager.indexOf(t) != 0) && t instanceof PageMapElement) || ((t.brailleList.getFirst().start != 0 && manager.indexOf(t) != 0) && t instanceof BrlOnlyMapElement)){
-                       index--;
-                       t = manager.getTextMapElement(index);
+               if(t == null){
+                       int i = 1;
+                       while(t == null && view.getCaretOffset() - 1 >= 0)
+                       t = 
manager.getElementInBrailleRange(view.getCaretOffset() - i);
+                       i--;
                }

-               currentChar = SWT.ARROW_UP;
-               if(t instanceof PageMapElement || t instanceof 
BrlOnlyMapElement){
-                       view.setCaretOffset(t.brailleList.getLast().end);
-                       nextValidPosition();
+               if(t != null){
+                       int index= manager.indexOf(t);
+ while(((t.brailleList.getFirst().start != 0 && manager.indexOf(t) != 0) && t instanceof PageMapElement) || ((t.brailleList.getFirst().start != 0 && manager.indexOf(t) != 0) && t instanceof BrlOnlyMapElement)){
+                               index--;
+                               t = manager.getTextMapElement(index);
+                       }
+
+                       currentChar = SWT.ARROW_UP;
+                       if(t instanceof PageMapElement || t instanceof 
BrlOnlyMapElement){
+                               
view.setCaretOffset(t.brailleList.getLast().end);
+                               nextValidPosition();
+                       }
+                       else
+                               
view.setCaretOffset(t.brailleList.getLast().end);
                }
-               else
-                       view.setCaretOffset(t.brailleList.getLast().end);
        }

        private void nextValidPosition(){
TextMapElement t = manager.getElementInBrailleRange(view.getCaretOffset());
-               int index = manager.indexOf(t);
- while(((t.brailleList.getLast().end != view.getCharCount() && manager.indexOf(t) != manager.getListSize() - 1) && t instanceof PageMapElement) || ((t.brailleList.getLast().end != view.getCharCount() && manager.indexOf(t) != manager.getListSize() - 1) && t instanceof BrlOnlyMapElement)){
-                       index++;
-                       t = manager.getTextMapElement(index);
+               if(t == null){
+                       int i = 1;
+                       while(t == null && view.getCaretOffset() + i <= 
view.getCharCount()){
+                               t = 
manager.getElementInBrailleRange(view.getCaretOffset() + i);
+                               i++;
+                       }
                }

-               currentChar = SWT.ARROW_DOWN;
-               if(t instanceof PageMapElement || t instanceof 
BrlOnlyMapElement){
-                       view.setCaretOffset(t.brailleList.getFirst().start);
-                       previousValidPosition();
+               if(t != null){
+                       int index = manager.indexOf(t);
+ while(((t.brailleList.getLast().end != view.getCharCount() && manager.indexOf(t) != manager.getListSize() - 1) && t instanceof PageMapElement) || ((t.brailleList.getLast().end != view.getCharCount() && manager.indexOf(t) != manager.getListSize() - 1) && t instanceof BrlOnlyMapElement)){
+                               index++;
+                               t = manager.getTextMapElement(index);
+                       }
+
+                       currentChar = SWT.ARROW_DOWN;
+                       if(t instanceof PageMapElement || t instanceof 
BrlOnlyMapElement){
+                               
view.setCaretOffset(t.brailleList.getFirst().start);
+                               previousValidPosition();
+                       }
+                       else
+                               
view.setCaretOffset(t.brailleList.getFirst().start);
                }
-               else
-                       view.setCaretOffset(t.brailleList.getFirst().start);
        }

        private void setCurrent(){
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Mon Jul 21 15:35:17 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Mon Jul 21 19:30:53 2014 UTC
@@ -293,9 +293,9 @@

                                                        
setCurrent(view.getCaretOffset());
if(currentElement instanceof PageMapElement|| currentElement instanceof BrlOnlyMapElement){ - if(nextStart != -1 && currentChar == SWT.ARROW_DOWN || currentChar == SWT.ARROW_RIGHT) + if((nextStart != -1 && (currentChar == SWT.ARROW_DOWN || currentChar == SWT.ARROW_RIGHT)) || (previousEnd == -1 && nextStart != -1 && (currentChar == SWT.ARROW_LEFT || currentChar == SWT.ARROW_UP)))
                                                                        
nextValidPosition();
- else if(previousEnd != -1 && currentChar == SWT.ARROW_LEFT || currentChar == SWT.ARROW_UP) + else if((previousEnd != -1 && (currentChar == SWT.ARROW_LEFT || currentChar == SWT.ARROW_UP)) || (nextStart == -1 && previousEnd != - 1 && (currentChar == SWT.ARROW_DOWN || currentChar == SWT.ARROW_RIGHT)))
                                                                        
previousValidPosition();
                                                        }

@@ -433,36 +433,54 @@

        private void nextValidPosition(){
                TextMapElement t = 
manager.getElementInRange(view.getCaretOffset());
-               int index = manager.indexOf(t);
- while(((t.end != view.getCharCount() && manager.indexOf(t) != manager.getListSize() - 1) && t instanceof PageMapElement) || ((t.end != view.getCharCount() && manager.indexOf(t) != manager.getListSize() - 1) &&t instanceof BrlOnlyMapElement)){
-                       index++;
-                       t = manager.getTextMapElement(index);
+               if(t == null){
+                       int i = 1;
+                       while(t == null && view.getCaretOffset() + i <= 
view.getCharCount()){
+                               t = 
manager.getElementInRange(view.getCaretOffset() + i);
+                               i++;
+                       }
                }
+               if(t != null){
+                       int index = manager.indexOf(t);
+ while(((t.end != view.getCharCount() && manager.indexOf(t) != manager.getListSize() - 1) && t instanceof PageMapElement) || ((t.end != view.getCharCount() && manager.indexOf(t) != manager.getListSize() - 1) &&t instanceof BrlOnlyMapElement)){
+                               index++;
+                               t = manager.getTextMapElement(index);
+                       }

-               currentChar = SWT.ARROW_DOWN;
-               if(t instanceof PageMapElement || t instanceof 
BrlOnlyMapElement){
-                       view.setCaretOffset(t.start);
-                       previousValidPosition();
+                       currentChar = SWT.ARROW_DOWN;
+                       if(t instanceof PageMapElement || t instanceof 
BrlOnlyMapElement){
+                               view.setCaretOffset(t.start);
+                               previousValidPosition();
+                       }
+                       else
+                               view.setCaretOffset(t.start);
                }
-               else
-                       view.setCaretOffset(t.start);
        }

        private void previousValidPosition(){
                TextMapElement t = 
manager.getElementInRange(view.getCaretOffset());
-               int index = manager.indexOf(t);
- while(((t.start != 0 && manager.indexOf(t) != 0) && t instanceof PageMapElement )|| ((t.start != 0 && manager.indexOf(t) != 0) && t instanceof BrlOnlyMapElement)){
-                       index--;
-                       t = manager.getTextMapElement(index);
+               if(t == null){
+                       int i = 1;
+                       while(t == null && view.getCaretOffset() - 1 >= 0)
+                       t = manager.getElementInRange(view.getCaretOffset() - 
i);
+                       i--;
                }

-               currentChar = SWT.ARROW_UP;
-               if(t instanceof PageMapElement || t instanceof 
BrlOnlyMapElement){
-                       view.setCaretOffset(t.end);
-                       nextValidPosition();
+               if(t != null){
+                       int index = manager.indexOf(t);
+ while(((t.start != 0 && manager.indexOf(t) != 0) && t instanceof PageMapElement )|| ((t.start != 0 && manager.indexOf(t) != 0) && t instanceof BrlOnlyMapElement)){
+                               index--;
+                               t = manager.getTextMapElement(index);
+                       }
+
+                       currentChar = SWT.ARROW_UP;
+                       if(t instanceof PageMapElement || t instanceof 
BrlOnlyMapElement){
+                               view.setCaretOffset(t.end);
+                               nextValidPosition();
+                       }
+                       else
+                               view.setCaretOffset(t.end);
                }
-               else
-                       view.setCaretOffset(t.end);
        }

//public method to check if an update should be made before exiting or saving

Other related posts:

  • » [brailleblaster] push by brandon....@xxxxxxxxx - Fixed bug in skipping read only sections that appear first in a docume... on 2014-07-21 19:32 GMT - brailleblaster