Преглед на файлове

Added "Goto line' to Ted2.

Mark Sibly преди 9 години
родител
ревизия
6529a213c3
променени са 2 файла, в които са добавени 20 реда и са изтрити 0 реда
  1. 19 0
      src/ted2/editactions.monkey2
  2. 1 0
      src/ted2/mainwindow.monkey2

+ 19 - 0
src/ted2/editactions.monkey2

@@ -10,6 +10,7 @@ Class EditActions
 	Field paste:Action
 	Field selectAll:Action
 	Field wordWrap:Action
+	Field gotoLine:Action
 	
 	Method New( docs:DocumentManager )
 	
@@ -35,6 +36,11 @@ Class EditActions
 		
 		wordWrap=New Action( "Toggle word wrap" )
 		wordWrap.Triggered=OnWordWrap
+		
+		gotoLine=New Action( "Goto line" )
+		gotoLine.Triggered=OnGotoLine
+		gotoLine.HotKey=Key.G
+		gotoLine.HotKeyModifiers=Modifier.Menu
 	End
 	
 	Method Update()
@@ -101,5 +107,18 @@ Class EditActions
 		
 		If tv tv.WordWrap=Not tv.WordWrap
 	End
+	
+	Method OnGotoLine()
+	
+		Local tv:=Cast<TextView>( App.KeyView )
+		If Not tv Return
+		
+		Local line:=RequestInt( "Goto line:","Goto line",tv.CursorLine+1,0,1,tv.Document.NumLines )
+		If Not line Return
+		
+		tv.GotoLine( line-1 )
+		
+		tv.MakeKeyView()
+	End
 
 End

+ 1 - 0
src/ted2/mainwindow.monkey2

@@ -156,6 +156,7 @@ Class MainWindowInstance Extends Window
 		_editMenu.AddAction( _findActions.findPrevious )
 		_editMenu.AddAction( _findActions.replace )
 		_editMenu.AddAction( _findActions.replaceAll )
+		_editMenu.AddAction( _editActions.gotoLine )
 		
 		'Build menu
 		'