Skip to content

Commit

Permalink
scroll to 0 if another file is opened
Browse files Browse the repository at this point in the history
  • Loading branch information
xulihang committed Feb 16, 2021
1 parent dff86b2 commit d5299d9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
11 changes: 7 additions & 4 deletions BasicCAT/BasicCAT.b4j
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,13 @@ Sub MenuBar1_Action
End Sub

Sub ScrollTo(index As Int)
editorLV.ScrollTo(Max(0,index-1))
If Abs(currentProject.lastEntry-index)>20 Then
Sleep(500)
If editorLV.Items.Size<>0 Then
editorLV.ScrollTo(Max(0,index-1))
If Abs(currentProject.lastEntry-index)>20 Then
Log("long range")
Sleep(500)
editorLV.ScrollTo(Max(0,index-1))
End If
End If
End Sub

Expand Down Expand Up @@ -1841,7 +1844,7 @@ Sub searchTableView_Action
Dim lbl As Label=searchTableView.SelectedRowValues(0)
Dim index As Int
index=lbl.Text
editorLV.ScrollTo(index)
ScrollTo(index)
End If
End Select
End Sub
Expand Down
4 changes: 2 additions & 2 deletions BasicCAT/BasicCAT.b4j.meta
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,6 @@ ModuleClosedNodes8=
ModuleClosedNodes80=
ModuleClosedNodes81=
ModuleClosedNodes9=
NavigationStack=Project,targetTextArea_FocusChanged,1705,5,Project,Class_Globals,20,0,progressDialog,update2,36,0,Project,addTextAreaToSegmentPane,1330,0,Project,targetTextArea_KeyPressed,1626,6,Project,changeSegment,1640,6,Main,MenuBar1_Action,344,0,Main,editSource,487,0,Main,fillWithTMOrMT,700,0,Project,mi_Action,1470,0,Project,openFile,253,3
NavigationStack=Project,mi_Action,1470,0,Project,closeFile,270,0,Main,changeNeglectedStatus,944,0,searchAndReplaceDialog,resultListView_Action,551,0,FontPicker,Initialize,22,0,Project,changeSegment,1662,0,Main,searchTableView_Action,1553,0,Main,MenuBar1_Action,344,0,Main,ScrollTo,469,6,Project,openFile,263,5
SelectedBuild=0
VisibleModules=1,2,3,4,5,6,7,8,9,10,23,36
VisibleModules=1,2,3,4,5,6,7,8,9,10,23,36,19,75
7 changes: 4 additions & 3 deletions BasicCAT/Project.bas
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,16 @@ Sub openFile(filename As String,onOpeningProject As Boolean)
readWorkFile(currentFilename,segments,True,path)
allsegments.AddAll(segments)
Log("currentFilename:"&currentFilename)
If lastFilename=currentFilename And segments.Size<>0 Then
Log("ddd"&True)
Log(lastEntry)
If lastFilename=currentFilename Then
Try
Main.ScrollTo(lastEntry)
Catch
lastEntry=0
Log(LastException)
End Try
Else
lastEntry=0
Main.ScrollTo(lastEntry)
End If
Dim visibleRange As Range
visibleRange=Main.getVisibleRange(Main.editorLV)
Expand Down
2 changes: 1 addition & 1 deletion BasicCAT/searchAndReplaceDialog.bas
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ Sub resultListView_Action
If filename<>Main.currentProject.currentFilename Then
Main.currentProject.openFile(filename,False)
End If
Main.editorLV.ScrollTo(tagMap.get("index"))
Main.ScrollTo(tagMap.get("index"))
Main.MainForm.AlwaysOnTop=True
Main.MainForm.AlwaysOnTop=False
End Select
Expand Down

0 comments on commit d5299d9

Please sign in to comment.