11package edu .ysu .itrace .gaze .handlers ;
22
3- import org .eclipse .jface .text .source .projection .ProjectionViewer ;
3+ // import org.eclipse.jface.text.source.projection.ProjectionViewer;
44import org .eclipse .swt .custom .StyledText ;
55import org .eclipse .swt .graphics .Point ;
66
1616 */
1717public class StyledTextGazeHandler implements IGazeHandler {
1818 private StyledText targetStyledText ;
19- private ProjectionViewer projectionViewer ;
19+ // private ProjectionViewer projectionViewer;
2020
2121 /**
2222 * Constructs a new gaze handler for the target StyledText object
@@ -43,16 +43,18 @@ public IStyledTextGazeResponse handleGaze(int absoluteX, int absoluteY,
4343 return null ;
4444 AstManager astManager = (AstManager ) targetStyledText
4545 .getData (ControlView .KEY_AST );
46- projectionViewer = astManager .getProjectionViewer ();
47- int lineOffset = targetStyledText .getOffsetAtLine (targetStyledText .getLineIndex (relativeY ));
46+ //projectionViewer = astManager.getProjectionViewer();
47+ lineIndex = targetStyledText .getLineIndex (relativeY );
48+ int lineOffset = targetStyledText .getOffsetAtLine (lineIndex );
49+ //int lineOffset = targetStyledText.getOffsetAtLine(targetStyledText.getLineIndex(relativeY));
4850 int offset ;
4951 try {
5052 offset = targetStyledText .getOffsetAtLocation (new Point (relativeX , relativeY ));
5153 }catch (IllegalArgumentException ex ){
5254 return null ;
5355 }
5456 col = offset - lineOffset ;
55- lineIndex = projectionViewer .widgetLine2ModelLine (targetStyledText .getLineIndex (relativeY ));
57+ // lineIndex = projectionViewer.widgetLine2ModelLine(targetStyledText.getLineIndex(relativeY));
5658
5759 // (0, 0) relative to the control in absolute screen
5860 // coordinates.
@@ -93,8 +95,16 @@ public String getName() {
9395
9496 @ Override
9597 public String getGazeType () {
96- String [] splitPath = path .split ("\\ ." );
97- String type = splitPath [splitPath .length -1 ];
98+ /*String[] splitPath = path.split("\\.");
99+ String type = splitPath[splitPath.length-1];*/
100+ String type = path ;
101+ int dotIndex ;
102+ for (dotIndex =0 ; dotIndex <type .length ();dotIndex ++)
103+ if (path .charAt (dotIndex ) == '.' )
104+ break ;
105+ if (dotIndex +1 == type .length ())
106+ return "text" ;
107+ type = type .substring (dotIndex +1 );
98108 return type ;
99109 }
100110
0 commit comments