Selaa lähdekoodia

Squashed 'src/ted2go/' changes from 5de45d560..eab9c36bd

eab9c36bd Merge branch 'dev'
533d90c47 Fix for onengl "es" mode.
c1c357772 Now IDE stores jump position for errors and debugstop (#132).
c588fec72 Fixed "Copy all not copying blank lines at top of file" (#131)
5d2075e37 Fixed renaming of file/folder opened in editor.

git-subtree-dir: src/ted2go
git-subtree-split: eab9c36bd2ffe072b18878aaaafc5ddcca012ba0
Mark Sibly 7 vuotta sitten
vanhempi
commit
38f3f97b20

+ 19 - 3
MainWindow.monkey2

@@ -39,7 +39,7 @@ Class MainWindowInstance Extends Window
 		_docBrowser=Di.Resolve<DocBrowserView>()
 		_docBrowser=Di.Resolve<DocBrowserView>()
 		
 		
 		_docsManager=Di.Resolve<DocumentManager>()
 		_docsManager=Di.Resolve<DocumentManager>()
-		
+
 		_docsManager.CurrentDocumentChanged+=Lambda()
 		_docsManager.CurrentDocumentChanged+=Lambda()
 			
 			
 			UpdateKeyView()
 			UpdateKeyView()
@@ -238,14 +238,30 @@ Class MainWindowInstance Extends Window
 			_findActions.FindInFiles( folder )
 			_findActions.FindInFiles( folder )
 		End
 		End
 		
 		
-		_codeParsing=New CodeParsing( _docsManager,_projectView )
+		_codeParsing=Di.Resolve<CodeParsing>()
 		
 		
 		_projectView.MainFileChanged+=Lambda( path:String,prevPath:String )
 		_projectView.MainFileChanged+=Lambda( path:String,prevPath:String )
-		
+			
 			_docsManager.SetAsMainFile( prevPath,False )
 			_docsManager.SetAsMainFile( prevPath,False )
 			_docsManager.SetAsMainFile( path,True )
 			_docsManager.SetAsMainFile( path,True )
 		End
 		End
 		
 		
+		_projectView.FileRenamed+=Lambda( path:String,prevPath:String )
+			
+			Local doc:=_docsManager.FindDocument( prevPath )
+			If doc Then _docsManager.RenameDocument( doc,path )
+		End
+		
+		_projectView.FolderRenamed+=Lambda( path:String,prevPath:String )
+			
+			Local docs:=_docsManager.OpenDocuments
+			For Local doc:=Eachin docs
+				If doc.Path.StartsWith( prevPath )
+					_docsManager.RenameDocument( doc,doc.Path.Replace( prevPath,path ) )
+				Endif
+			Next
+		End
+		
 		_fileActions=New FileActions( _docsManager )
 		_fileActions=New FileActions( _docsManager )
 		_editActions=New EditActions( _docsManager )
 		_editActions=New EditActions( _docsManager )
 		_findActions=New FindActions( _docsManager,_projectView,_findConsole )
 		_findActions=New FindActions( _docsManager,_projectView,_findConsole )

+ 1 - 1
Prefs.monkey2

@@ -127,7 +127,7 @@ Class PrefsInstance
 		j["projectIcons"]=New JsonBool( MainProjectIcons )
 		j["projectIcons"]=New JsonBool( MainProjectIcons )
 		j["singleClickExpanding"]=New JsonBool( MainProjectSingleClickExpanding )
 		j["singleClickExpanding"]=New JsonBool( MainProjectSingleClickExpanding )
 		j["placeDocsAtBegin"]=New JsonBool( MainPlaceDocsAtBegin )
 		j["placeDocsAtBegin"]=New JsonBool( MainPlaceDocsAtBegin )
-		j["openglProfile"]=New JsonBool( OpenGlProfile )
+		j["openglProfile"]=New JsonString( OpenGlProfile )
 		
 		
 		j=New JsonObject
 		j=New JsonObject
 		json["completion"]=j
 		json["completion"]=j

+ 3 - 11
action/BuildActions.monkey2

@@ -334,17 +334,9 @@ Class BuildActions Implements IModuleBuilder
 	End
 	End
 	
 	
 	Method GotoError( err:BuildError )
 	Method GotoError( err:BuildError )
-	
-		Local doc:=Cast<CodeDocument>( _docs.OpenDocument( GetCaseSensitivePath( err.path ),True ) )
-		If Not doc Return
-	
-		Local tv := doc.CodeView
-		If Not tv Return
-	
-		MainWindow.UpdateWindow( False )
-	
-		tv.GotoPosition( New Vec2i( err.line,0 ) )
-		tv.MakeKeyView()
+		
+		Local targetPath:=GetCaseSensitivePath( err.path )
+		_docs.CurrentCodeDocument?.JumpToPosition( targetPath,New Vec2i( err.line,0 ) )
 	End
 	End
 	
 	
 	
 	

+ 5 - 0
di/DiSetup.monkey2

@@ -47,6 +47,11 @@ Function SetupDiContainer()
 		Return view
 		Return view
 	End )
 	End )
 	
 	
+	Di.Bind( Lambda:CodeParsing()
+		Return New CodeParsing(
+			Di.Resolve<DocumentManager>(),
+			Di.Resolve<ProjectView>() )
+	End )
 End
 End
 
 
 
 

+ 19 - 6
document/CodeDocument.monkey2

@@ -1200,17 +1200,30 @@ Class CodeDocument Extends Ted2Document
 		Return _doc
 		Return _doc
 	End
 	End
 	
 	
+	Method JumpToDebugLine( path:String,line:Int )
+		
+		Local doc:=Cast<CodeDocument>( MainWindow.DocsManager.OpenDocument( path,True ) )
+		If doc
+			MainWindow.UpdateWindow( False )
+			Local haveNoLine:=(doc.DebugLine=-1)
+			Local pos:=New Vec2i( line,0 )
+			If haveNoLine
+				JumpToPosition( path,pos ) 'store jump position
+			Else
+				doc._codeView.GotoPosition( pos,0 )
+			Endif
+			doc?.DebugLine=line
+		Endif
+	End
+	
 	Property DebugLine:Int()
 	Property DebugLine:Int()
 	
 	
 		Return _debugLine
 		Return _debugLine
 	
 	
 	Setter( debugLine:Int )
 	Setter( debugLine:Int )
-		If debugLine=_debugLine Return
 		
 		
 		_debugLine=debugLine
 		_debugLine=debugLine
-		If _debugLine=-1 Return
 		
 		
-		_codeView.GotoLine( _debugLine )
 	End
 	End
 	
 	
 	Property Errors:Stack<BuildError>()
 	Property Errors:Stack<BuildError>()
@@ -2053,7 +2066,7 @@ End
 Class NavOps<T>
 Class NavOps<T>
 	
 	
 	Field OnNavigate:Void( target:T )
 	Field OnNavigate:Void( target:T )
-		
+	
 	Method Navigate( value:T )
 	Method Navigate( value:T )
 		
 		
 		Push( value )
 		Push( value )
@@ -2085,7 +2098,7 @@ Class NavOps<T>
 			Return
 			Return
 		Endif
 		Endif
 		Local value:=_items[_index]
 		Local value:=_items[_index]
-
+		
 		OnNavigate( value )
 		OnNavigate( value )
 	End
 	End
 	
 	
@@ -2097,7 +2110,7 @@ Class NavOps<T>
 			Return
 			Return
 		Endif
 		Endif
 		Local value:=_items[_index]
 		Local value:=_items[_index]
-
+		
 		OnNavigate( value )
 		OnNavigate( value )
 	End
 	End
 	
 	

+ 3 - 4
view/CodeTextView.monkey2

@@ -884,7 +884,6 @@ Class CodeTextView Extends TextView
 		For Local i:=1 Until lines.Length
 		For Local i:=1 Until lines.Length
 			Local s:=lines[i]
 			Local s:=lines[i]
 			If result Then result+="~n"
 			If result Then result+="~n"
-			If Not s.Trim() Continue 'empty
 			result+=s.Slice( indent2 )
 			result+=s.Slice( indent2 )
 		Next
 		Next
 	
 	
@@ -949,7 +948,7 @@ Class CodeTextView Extends TextView
 		txt=txt.Replace( "~r~n","~n" )
 		txt=txt.Replace( "~r~n","~n" )
 		txt=txt.Replace( "~r","~n" )
 		txt=txt.Replace( "~r","~n" )
 		Local lines:=txt.Split( "~n" )
 		Local lines:=txt.Split( "~n" )
-	
+		
 		' add indent at cursor
 		' add indent at cursor
 		If indent
 		If indent
 			Local add:=Utils.RepeatStr( "~t",indent )
 			Local add:=Utils.RepeatStr( "~t",indent )
@@ -961,10 +960,10 @@ Class CodeTextView Extends TextView
 		' result text
 		' result text
 		Local result:=""
 		Local result:=""
 		For Local i:=0 Until lines.Length
 		For Local i:=0 Until lines.Length
-			If result Then result+="~n"
+			If i>0 Then result+="~n"
 			result+=lines[i]
 			result+=lines[i]
 		Next
 		Next
-	
+		
 		Return result
 		Return result
 	End
 	End
 	
 	

+ 7 - 11
view/DebugView.monkey2

@@ -126,11 +126,11 @@ Class DebugView Extends DockingView
 	End
 	End
 	
 	
 	Method DebugApp( appFile:String,config:String )
 	Method DebugApp( appFile:String,config:String )
-	
+		
 		If _console.Running Return
 		If _console.Running Return
-
+		
 		_console.Clear()
 		_console.Clear()
-			
+		
 		MainWindow.ShowOutputConsole()
 		MainWindow.ShowOutputConsole()
 	
 	
 		Local cmd:="~q"+RealPath( appFile )+"~q"
 		Local cmd:="~q"+RealPath( appFile )+"~q"
@@ -355,7 +355,7 @@ Class DebugView Extends DockingView
 				Local bits:=line.Split( ";" )
 				Local bits:=line.Split( ";" )
 				Local label:=bits[0].Slice( 1 )
 				Local label:=bits[0].Slice( 1 )
 				Local seq:=Int( bits[3] )
 				Local seq:=Int( bits[3] )
-
+				
 				func=Null
 				func=Null
 				For Local i:=funcIndex Until root.NumChildren
 				For Local i:=funcIndex Until root.NumChildren
 					Local tfunc:=Cast<Node>( root.GetChild( i ) )
 					Local tfunc:=Cast<Node>( root.GetChild( i ) )
@@ -373,16 +373,12 @@ Class DebugView Extends DockingView
 					func.srcFile=bits[1]
 					func.srcFile=bits[1]
 					func.srcLine=Int( bits[2] )
 					func.srcLine=Int( bits[2] )
 					func.seq=seq
 					func.seq=seq
-
+					
 					If Not first func.Expanded=True
 					If Not first func.Expanded=True
 				Endif
 				Endif
 				
 				
 				If Not first
 				If Not first
-					Local doc:=Cast<CodeDocument>( _docs.OpenDocument( func.srcFile,True ) )
-					If doc
-						MainWindow.UpdateWindow( False )
-						doc.DebugLine=func.srcLine-1
-					Endif
+					_docs.CurrentCodeDocument?.JumpToDebugLine( func.srcFile,func.srcLine-1 )
 					first=func
 					first=func
 				Endif
 				Endif
 				
 				
@@ -426,7 +422,7 @@ Class DebugView Extends DockingView
 		
 		
 		_killme=False
 		_killme=False
 		_debugging=True
 		_debugging=True
-
+		
 		UpdateActions()
 		UpdateActions()
 	End
 	End
 	
 	

+ 6 - 3
view/ProjectView.monkey2

@@ -14,6 +14,8 @@ Class ProjectView Extends DockingView
 	
 	
 	Field RequestedFindInFolder:Void( folder:String )
 	Field RequestedFindInFolder:Void( folder:String )
 	Field MainFileChanged:Void( path:String,prevPath:String )
 	Field MainFileChanged:Void( path:String,prevPath:String )
+	Field FileRenamed:Void( path:String,prevPath:String )
+	Field FolderRenamed:Void( path:String,prevPath:String )
 	
 	
 	Method New( docs:DocumentManager,builder:IModuleBuilder )
 	Method New( docs:DocumentManager,builder:IModuleBuilder )
 	
 	
@@ -629,13 +631,14 @@ Class ProjectView Extends DockingView
 							Return
 							Return
 						Endif
 						Endif
 						
 						
-						Local ok:=(libc.rename( path,newPath )=0)
-						If ok
+						Local code:=libc.rename( path,newPath )
+						If code=0
 							browser.Refresh( node.Parent )
 							browser.Refresh( node.Parent )
+							FolderRenamed( newPath,path )
 							Return
 							Return
 						Endif
 						Endif
 					
 					
-						Alert( "Failed to rename folder: '"+path+"'" )
+						Alert( "Failed to rename folder: '"+path+"'. Error code: "+code )
 					Endif
 					Endif
 				End
 				End