1
1
package edu .ysu .itrace .gaze .handlers ;
2
2
3
- import org .eclipse .jface .text .source .projection .ProjectionViewer ;
3
+ // import org.eclipse.jface.text.source.projection.ProjectionViewer;
4
4
import org .eclipse .swt .custom .StyledText ;
5
5
import org .eclipse .swt .graphics .Point ;
6
6
16
16
*/
17
17
public class StyledTextGazeHandler implements IGazeHandler {
18
18
private StyledText targetStyledText ;
19
- private ProjectionViewer projectionViewer ;
19
+ // private ProjectionViewer projectionViewer;
20
20
21
21
/**
22
22
* Constructs a new gaze handler for the target StyledText object
@@ -43,16 +43,18 @@ public IStyledTextGazeResponse handleGaze(int absoluteX, int absoluteY,
43
43
return null ;
44
44
AstManager astManager = (AstManager ) targetStyledText
45
45
.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));
48
50
int offset ;
49
51
try {
50
52
offset = targetStyledText .getOffsetAtLocation (new Point (relativeX , relativeY ));
51
53
}catch (IllegalArgumentException ex ){
52
54
return null ;
53
55
}
54
56
col = offset - lineOffset ;
55
- lineIndex = projectionViewer .widgetLine2ModelLine (targetStyledText .getLineIndex (relativeY ));
57
+ // lineIndex = projectionViewer.widgetLine2ModelLine(targetStyledText.getLineIndex(relativeY));
56
58
57
59
// (0, 0) relative to the control in absolute screen
58
60
// coordinates.
@@ -93,8 +95,16 @@ public String getName() {
93
95
94
96
@ Override
95
97
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 );
98
108
return type ;
99
109
}
100
110
0 commit comments