Mercurial > projects > dwt-addons
comparison dwtx/jface/text/TextViewer.d @ 137:25170b5a8951
Regex this.outer change
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 02:22:48 +0200 |
parents | 6dcb0baaa031 |
children | b6bad70d540a |
comparison
equal
deleted
inserted
replaced
136:6dcb0baaa031 | 137:25170b5a8951 |
---|---|
812 * Installs this range. The range registers itself as background | 812 * Installs this range. The range registers itself as background |
813 * line painter and text listener. Also, it creates a category with the | 813 * line painter and text listener. Also, it creates a category with the |
814 * viewer's document to maintain its own extent. | 814 * viewer's document to maintain its own extent. |
815 */ | 815 */ |
816 public void install() { | 816 public void install() { |
817 TextViewer.this.addTextListener(this); | 817 this.outer.addTextListener(this); |
818 fTextWidget.addLineBackgroundListener(this); | 818 fTextWidget.addLineBackgroundListener(this); |
819 | 819 |
820 IDocument document= TextViewer.this.getDocument(); | 820 IDocument document= this.outer.getDocument(); |
821 try { | 821 try { |
822 document.addPositionCategory(RANGE_CATEGORY); | 822 document.addPositionCategory(RANGE_CATEGORY); |
823 document.addPosition(RANGE_CATEGORY, fPosition); | 823 document.addPosition(RANGE_CATEGORY, fPosition); |
824 document.addPositionUpdater(this); | 824 document.addPositionUpdater(this); |
825 } catch (BadPositionCategoryException e) { | 825 } catch (BadPositionCategoryException e) { |
837 */ | 837 */ |
838 public void uninstall() { | 838 public void uninstall() { |
839 | 839 |
840 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19612 | 840 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19612 |
841 | 841 |
842 IDocument document= TextViewer.this.getDocument(); | 842 IDocument document= this.outer.getDocument(); |
843 if (document !is null) { | 843 if (document !is null) { |
844 document.removePositionUpdater(this); | 844 document.removePositionUpdater(this); |
845 document.removePosition(fPosition); | 845 document.removePosition(fPosition); |
846 } | 846 } |
847 | 847 |
848 if (fTextWidget !is null && !fTextWidget.isDisposed()) | 848 if (fTextWidget !is null && !fTextWidget.isDisposed()) |
849 fTextWidget.removeLineBackgroundListener(this); | 849 fTextWidget.removeLineBackgroundListener(this); |
850 | 850 |
851 TextViewer.this.removeTextListener(this); | 851 this.outer.removeTextListener(this); |
852 | 852 |
853 clear(); | 853 clear(); |
854 } | 854 } |
855 | 855 |
856 /** | 856 /** |
928 | 928 |
929 /* | 929 /* |
930 * @see IFindReplaceTarget#getSelectionText() | 930 * @see IFindReplaceTarget#getSelectionText() |
931 */ | 931 */ |
932 public String getSelectionText() { | 932 public String getSelectionText() { |
933 Point s= TextViewer.this.getSelectedRange(); | 933 Point s= this.outer.getSelectedRange(); |
934 if (s.x > -1 && s.y > -1) { | 934 if (s.x > -1 && s.y > -1) { |
935 try { | 935 try { |
936 IDocument document= TextViewer.this.getDocument(); | 936 IDocument document= this.outer.getDocument(); |
937 return document.get(s.x, s.y); | 937 return document.get(s.x, s.y); |
938 } catch (BadLocationException x) { | 938 } catch (BadLocationException x) { |
939 } | 939 } |
940 } | 940 } |
941 return ""; //$NON-NLS-1$ | 941 return ""; //$NON-NLS-1$ |
950 | 950 |
951 /* | 951 /* |
952 * @see IFindReplaceTarget#replaceSelection(String) | 952 * @see IFindReplaceTarget#replaceSelection(String) |
953 */ | 953 */ |
954 public void replaceSelection(String text, bool regExReplace) { | 954 public void replaceSelection(String text, bool regExReplace) { |
955 Point s= TextViewer.this.getSelectedRange(); | 955 Point s= this.outer.getSelectedRange(); |
956 if (s.x > -1 && s.y > -1) { | 956 if (s.x > -1 && s.y > -1) { |
957 try { | 957 try { |
958 IRegion matchRegion= TextViewer.this.getFindReplaceDocumentAdapter().replace(text, regExReplace); | 958 IRegion matchRegion= this.outer.getFindReplaceDocumentAdapter().replace(text, regExReplace); |
959 int length= -1; | 959 int length= -1; |
960 if (matchRegion !is null) | 960 if (matchRegion !is null) |
961 length= matchRegion.getLength(); | 961 length= matchRegion.getLength(); |
962 | 962 |
963 if (text !is null && length > 0) | 963 if (text !is null && length > 0) |
964 TextViewer.this.setSelectedRange(s.x, length); | 964 this.outer.setSelectedRange(s.x, length); |
965 } catch (BadLocationException x) { | 965 } catch (BadLocationException x) { |
966 } | 966 } |
967 } | 967 } |
968 } | 968 } |
969 | 969 |
970 /* | 970 /* |
971 * @see IFindReplaceTarget#isEditable() | 971 * @see IFindReplaceTarget#isEditable() |
972 */ | 972 */ |
973 public bool isEditable() { | 973 public bool isEditable() { |
974 return TextViewer.this.isEditable(); | 974 return this.outer.isEditable(); |
975 } | 975 } |
976 | 976 |
977 /* | 977 /* |
978 * @see IFindReplaceTarget#getSelection() | 978 * @see IFindReplaceTarget#getSelection() |
979 */ | 979 */ |
980 public Point getSelection() { | 980 public Point getSelection() { |
981 Point modelSelection= TextViewer.this.getSelectedRange(); | 981 Point modelSelection= this.outer.getSelectedRange(); |
982 Point widgetSelection= modelSelection2WidgetSelection(modelSelection); | 982 Point widgetSelection= modelSelection2WidgetSelection(modelSelection); |
983 return widgetSelection !is null ? widgetSelection : new Point(-1, -1); | 983 return widgetSelection !is null ? widgetSelection : new Point(-1, -1); |
984 } | 984 } |
985 | 985 |
986 /* | 986 /* |
1001 | 1001 |
1002 int modelOffset= widgetOffset is -1 ? -1 : widgetOffset2ModelOffset(widgetOffset); | 1002 int modelOffset= widgetOffset is -1 ? -1 : widgetOffset2ModelOffset(widgetOffset); |
1003 | 1003 |
1004 if (fRange !is null) { | 1004 if (fRange !is null) { |
1005 IRegion range= fRange.getRange(); | 1005 IRegion range= fRange.getRange(); |
1006 modelOffset= TextViewer.this.findAndSelectInRange(modelOffset, findString, searchForward, caseSensitive, wholeWord, range.getOffset(), range.getLength(), regExSearch); | 1006 modelOffset= this.outer.findAndSelectInRange(modelOffset, findString, searchForward, caseSensitive, wholeWord, range.getOffset(), range.getLength(), regExSearch); |
1007 } else { | 1007 } else { |
1008 modelOffset= TextViewer.this.findAndSelect(modelOffset, findString, searchForward, caseSensitive, wholeWord, regExSearch); | 1008 modelOffset= this.outer.findAndSelect(modelOffset, findString, searchForward, caseSensitive, wholeWord, regExSearch); |
1009 } | 1009 } |
1010 | 1010 |
1011 widgetOffset= modelOffset is -1 ? -1 : modelOffset2WidgetOffset(modelOffset); | 1011 widgetOffset= modelOffset is -1 ? -1 : modelOffset2WidgetOffset(modelOffset); |
1012 return widgetOffset; | 1012 return widgetOffset; |
1013 } | 1013 } |
1014 | 1014 |
1015 /* | 1015 /* |
1016 * @see IFindReplaceTarget#canPerformFind() | 1016 * @see IFindReplaceTarget#canPerformFind() |
1017 */ | 1017 */ |
1018 public bool canPerformFind() { | 1018 public bool canPerformFind() { |
1019 return TextViewer.this.canPerformFind(); | 1019 return this.outer.canPerformFind(); |
1020 } | 1020 } |
1021 | 1021 |
1022 /* | 1022 /* |
1023 * @see IFindReplaceTargetExtension#beginSession() | 1023 * @see IFindReplaceTargetExtension#beginSession() |
1024 * @since 2.0 | 1024 * @since 2.0 |
1049 /* | 1049 /* |
1050 * @see IFindReplaceTargetExtension#getLineSelection() | 1050 * @see IFindReplaceTargetExtension#getLineSelection() |
1051 * @since 2.0 | 1051 * @since 2.0 |
1052 */ | 1052 */ |
1053 public Point getLineSelection() { | 1053 public Point getLineSelection() { |
1054 Point point= TextViewer.this.getSelectedRange(); | 1054 Point point= this.outer.getSelectedRange(); |
1055 | 1055 |
1056 try { | 1056 try { |
1057 IDocument document= TextViewer.this.getDocument(); | 1057 IDocument document= this.outer.getDocument(); |
1058 | 1058 |
1059 // beginning of line | 1059 // beginning of line |
1060 int line= document.getLineOfOffset(point.x); | 1060 int line= document.getLineOfOffset(point.x); |
1061 int offset= document.getLineOffset(line); | 1061 int offset= document.getLineOffset(line); |
1062 | 1062 |
1080 /* | 1080 /* |
1081 * @see IFindReplaceTargetExtension#setSelection(int, int) | 1081 * @see IFindReplaceTargetExtension#setSelection(int, int) |
1082 * @since 2.0 | 1082 * @since 2.0 |
1083 */ | 1083 */ |
1084 public void setSelection(int modelOffset, int modelLength) { | 1084 public void setSelection(int modelOffset, int modelLength) { |
1085 TextViewer.this.setSelectedRange(modelOffset, modelLength); | 1085 this.outer.setSelectedRange(modelOffset, modelLength); |
1086 } | 1086 } |
1087 | 1087 |
1088 /* | 1088 /* |
1089 * @see IFindReplaceTargetExtension#setScope(IRegion) | 1089 * @see IFindReplaceTargetExtension#setScope(IRegion) |
1090 * @since 2.0 | 1090 * @since 2.0 |
1119 */ | 1119 */ |
1120 public void setReplaceAllMode(bool replaceAll) { | 1120 public void setReplaceAllMode(bool replaceAll) { |
1121 | 1121 |
1122 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18232 | 1122 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18232 |
1123 | 1123 |
1124 IDocument document= TextViewer.this.getDocument(); | 1124 IDocument document= this.outer.getDocument(); |
1125 | 1125 |
1126 if (replaceAll) { | 1126 if (replaceAll) { |
1127 | 1127 |
1128 if (document instanceof IDocumentExtension4) { | 1128 if (document instanceof IDocumentExtension4) { |
1129 IDocumentExtension4 extension= cast(IDocumentExtension4) document; | 1129 IDocumentExtension4 extension= cast(IDocumentExtension4) document; |
1130 fRewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL); | 1130 fRewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL); |
1131 } else { | 1131 } else { |
1132 TextViewer.this.setRedraw(false); | 1132 this.outer.setRedraw(false); |
1133 TextViewer.this.startSequentialRewriteMode(false); | 1133 this.outer.startSequentialRewriteMode(false); |
1134 | 1134 |
1135 if (fUndoManager !is null) | 1135 if (fUndoManager !is null) |
1136 fUndoManager.beginCompoundChange(); | 1136 fUndoManager.beginCompoundChange(); |
1137 | 1137 |
1138 fRememberedPartitioners= TextUtilities.removeDocumentPartitioners(document); | 1138 fRememberedPartitioners= TextUtilities.removeDocumentPartitioners(document); |
1142 | 1142 |
1143 if (document instanceof IDocumentExtension4) { | 1143 if (document instanceof IDocumentExtension4) { |
1144 IDocumentExtension4 extension= cast(IDocumentExtension4) document; | 1144 IDocumentExtension4 extension= cast(IDocumentExtension4) document; |
1145 extension.stopRewriteSession(fRewriteSession); | 1145 extension.stopRewriteSession(fRewriteSession); |
1146 } else { | 1146 } else { |
1147 TextViewer.this.setRedraw(true); | 1147 this.outer.setRedraw(true); |
1148 TextViewer.this.stopSequentialRewriteMode(); | 1148 this.outer.stopSequentialRewriteMode(); |
1149 | 1149 |
1150 if (fUndoManager !is null) | 1150 if (fUndoManager !is null) |
1151 fUndoManager.endCompoundChange(); | 1151 fUndoManager.endCompoundChange(); |
1152 | 1152 |
1153 if (fRememberedPartitioners !is null) | 1153 if (fRememberedPartitioners !is null) |
1182 | 1182 |
1183 /* | 1183 /* |
1184 * @see dwtx.jface.text.IRewriteTarget#getDocument() | 1184 * @see dwtx.jface.text.IRewriteTarget#getDocument() |
1185 */ | 1185 */ |
1186 public IDocument getDocument() { | 1186 public IDocument getDocument() { |
1187 return TextViewer.this.getDocument(); | 1187 return this.outer.getDocument(); |
1188 } | 1188 } |
1189 | 1189 |
1190 /* | 1190 /* |
1191 * @see dwtx.jface.text.IRewriteTarget#setRedraw(bool) | 1191 * @see dwtx.jface.text.IRewriteTarget#setRedraw(bool) |
1192 */ | 1192 */ |
1193 public void setRedraw(bool redraw) { | 1193 public void setRedraw(bool redraw) { |
1194 TextViewer.this.setRedraw(redraw); | 1194 this.outer.setRedraw(redraw); |
1195 } | 1195 } |
1196 } | 1196 } |
1197 | 1197 |
1198 /** | 1198 /** |
1199 * Value object used as key in the text hover configuration table. It is | 1199 * Value object used as key in the text hover configuration table. It is |
1539 | 1539 |
1540 /* | 1540 /* |
1541 * @see dwtx.jface.text.IDocumentRewriteSessionListener#documentRewriteSessionChanged(dwtx.jface.text.DocumentRewriteSessionEvent) | 1541 * @see dwtx.jface.text.IDocumentRewriteSessionListener#documentRewriteSessionChanged(dwtx.jface.text.DocumentRewriteSessionEvent) |
1542 */ | 1542 */ |
1543 public void documentRewriteSessionChanged(DocumentRewriteSessionEvent event) { | 1543 public void documentRewriteSessionChanged(DocumentRewriteSessionEvent event) { |
1544 IRewriteTarget target= TextViewer.this.getRewriteTarget(); | 1544 IRewriteTarget target= this.outer.getRewriteTarget(); |
1545 // FIXME always use setRedraw to avoid flickering due to scrolling | 1545 // FIXME always use setRedraw to avoid flickering due to scrolling |
1546 // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=158746 | 1546 // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=158746 |
1547 bool toggleRedraw= true || event.getSession().getSessionType() !is DocumentRewriteSessionType.UNRESTRICTED_SMALL; | 1547 bool toggleRedraw= true || event.getSession().getSessionType() !is DocumentRewriteSessionType.UNRESTRICTED_SMALL; |
1548 final bool viewportStabilize= !toggleRedraw; | 1548 final bool viewportStabilize= !toggleRedraw; |
1549 if (DocumentRewriteSessionEvent.SESSION_START is event.getChangeType()) { | 1549 if (DocumentRewriteSessionEvent.SESSION_START is event.getChangeType()) { |