소스 검색

Fixed TextView block tab and previous word.

Mark Sibly 8 년 전
부모
커밋
b1e6e62666
2개의 변경된 파일31개의 추가작업 그리고 13개의 파일을 삭제
  1. 4 4
      modules/mojox/tests/textview_test.monkey2
  2. 27 9
      modules/mojox/textview.monkey2

+ 4 - 4
modules/mojox/tests/textview_test.monkey2

@@ -1,9 +1,9 @@
 
-#import "<std>"
-#import "<mojo>"
-#import "<mojox>"
+#Import "<std>"
+#Import "<mojo>"
+#Import "<mojox>"
 
-#import "assets/mainwindow.monkey2@/"
+#Import "assets/mainwindow.monkey2@/"
 
 Using std..
 Using mojo..

+ 27 - 9
modules/mojox/textview.monkey2

@@ -894,15 +894,24 @@ Class TextView Extends ScrollableView
 			ReplaceText( "" )
 				
 		Case Key.Tab
+		
+			Local cmin:=Min( _cursor,_anchor )
+			Local cmax:=Max( _cursor,_anchor )
 			
-			Local min:=_doc.FindLine( Min( _cursor,_anchor ) )
-			Local max:=_doc.FindLine( Max( _cursor,_anchor ) )
+			Local min:=_doc.FindLine( cmin )
+			Local max:=_doc.FindLine( cmax )
 				
 			If min=max
 				ReplaceText( "~t" )
 			Else
+				'select all lines...
+				cmin=_doc.StartOfLine( min )
+				If _doc.StartOfLine( max )<>cmax 
+					max+=1
+					cmax=_doc.StartOfLine( max )
+				Endif
+				SelectText( cmin,cmax )
 				
-				'block tab/untab
 				Local lines:=New StringStack
 					
 				For Local i:=min Until max
@@ -936,7 +945,6 @@ Class TextView Extends ScrollableView
 				Endif
 					
 				If go
-					SelectText( _doc.StartOfLine( min ),_doc.StartOfLine( max ) )
 					ReplaceText( lines.Join( "" ) )
 					SelectText( _doc.StartOfLine( min ),_doc.StartOfLine( max ) )
 					Return False					
@@ -1043,29 +1051,39 @@ Class TextView Extends ScrollableView
 			UpdateCursor()
 			Return True
 		Case Key.Left
+		
 			If _anchor<>_cursor And Not (modifiers & Modifier.Shift)
 				_cursor=Min( _anchor,_cursor )
 			Endif
-			Local term:=New Int[1]
-			Local start:=FindWord( _cursor,term )
-			_cursor=Max( start-1,0 )
+			
 			Local text:=Text
+			Local term:=New Int[1]
+			_cursor=FindWord( _cursor,term )
+			
 			While _cursor And text[_cursor-1]<=32 And text[_cursor-1]<>10
 				_cursor-=1
 			Wend
+			
+			_cursor=FindWord( Max( _cursor-1,0 ),term )
 			UpdateCursor()
 			Return True
+
 		Case Key.Right
+		
 			If _anchor<>_cursor And Not (modifiers & Modifier.Shift)
 				_cursor=Max( _anchor,_cursor )
 			Endif
+		
+			'next word...	
+			Local text:=Text
 			Local term:=New Int[1]
-			Local start:=FindWord( _cursor,term )
+			FindWord( _cursor,term )
 			_cursor=term[0]
-			Local text:=Text
+			
 			While _cursor<text.Length And text[_cursor]<=32 And text[_cursor]<>10
 				_cursor+=1
 			Wend
+			
 			UpdateCursor()
 			Return True
 		End