Search dialog: The project browsing is now done through a background task.
[DEVELOPMENT ENVIRONMENT] * BUG: Code editor: The automatic completion now appears at the correct position when the view is splitted. * NEW: Search dialog: The project browsing is now done through a background task. * NEW: Redraw the module icons.
|
@ -42,20 +42,6 @@ Public Sub _new()
|
|||
.AddColumn(("Function"))
|
||||
End With
|
||||
|
||||
' With gvwFind
|
||||
' .Columns.Count = 5
|
||||
' .Columns[0].Width = DS * 16
|
||||
' .Columns[0].Text = ("File")
|
||||
' .Columns[1].Width = DS * 16
|
||||
' .Columns[1].Text = ("Location")
|
||||
' .Columns[2].Width = DS * 6
|
||||
' .Columns[2].Text = ("Line")
|
||||
' .Columns[3].Width = DS * 6
|
||||
' .Columns[3].Text = ("Col.")
|
||||
' .Columns[4].Width = 32
|
||||
' .Columns[4].Text = ("Text")
|
||||
' End With
|
||||
|
||||
With gvwFind
|
||||
.AddColumn(("File"))
|
||||
.AddColumn(("Location"))
|
||||
|
@ -628,6 +614,20 @@ Public Sub SetSearchListInfo(Optional sText As String)
|
|||
|
||||
End
|
||||
|
||||
Public Sub StartSearch()
|
||||
|
||||
spnSearch.Start
|
||||
spnSearch.Show
|
||||
|
||||
End
|
||||
|
||||
Public Sub StopSearch()
|
||||
|
||||
spnSearch.Stop
|
||||
spnSearch.Hide
|
||||
|
||||
End
|
||||
|
||||
Public Sub btnShowSearch_Click()
|
||||
|
||||
FSearch.WakeUp(False, True)
|
||||
|
|
|
@ -184,7 +184,7 @@
|
|||
Index = 5
|
||||
Text = ("Search result")
|
||||
{ panSearch HBox
|
||||
MoveScaled(1,0,83,4)
|
||||
MoveScaled(1,0,97,4)
|
||||
{ btnCancelSearch ToolButton
|
||||
MoveScaled(0,0,10,4)
|
||||
Visible = False
|
||||
|
@ -193,36 +193,41 @@
|
|||
Text = ("Cancel")
|
||||
Picture = Picture["icon:/small/halt"]
|
||||
}
|
||||
{ spnSearch Spinner
|
||||
MoveScaled(6,0,4,4)
|
||||
Visible = False
|
||||
Padding = 4
|
||||
}
|
||||
{ btnCloseSearch ToolButton
|
||||
MoveScaled(11,0,10,4)
|
||||
AutoResize = True
|
||||
Text = ("Close")
|
||||
Picture = Picture["icon:/small/close"]
|
||||
}
|
||||
{ btnRefreshSearch ToolButton
|
||||
MoveScaled(22,0,18,4)
|
||||
AutoResize = True
|
||||
Text = ("Search again")
|
||||
Picture = Picture["icon:/small/refresh"]
|
||||
}
|
||||
{ btnShowSearch ToolButton
|
||||
MoveScaled(41,0,19,4)
|
||||
MoveScaled(21,0,21,4)
|
||||
AutoResize = True
|
||||
Text = ("Show search window")
|
||||
Picture = Picture["icon:/small/find"]
|
||||
}
|
||||
{ btnRefreshSearch ToolButton
|
||||
MoveScaled(43,0,18,4)
|
||||
AutoResize = True
|
||||
Text = ("Search again")
|
||||
Picture = Picture["icon:/small/refresh"]
|
||||
}
|
||||
{ Panel1 Panel
|
||||
MoveScaled(62,0,2,4)
|
||||
Expand = True
|
||||
}
|
||||
{ lblBrowse Label
|
||||
MoveScaled(66,0,11,4)
|
||||
MoveScaled(77,0,11,4)
|
||||
Font = Font["Italic"]
|
||||
Padding = 4
|
||||
AutoResize = True
|
||||
}
|
||||
{ panButtonSearch Panel
|
||||
MoveScaled(78,0,4,4)
|
||||
MoveScaled(90,0,4,4)
|
||||
}
|
||||
}
|
||||
{ Separator5 Separator
|
||||
|
|
|
@ -225,6 +225,7 @@ Public Sub Open(hForm As Object, sMode As String, Optional sClass As String, Opt
|
|||
panResizeTop.Hide
|
||||
Endif
|
||||
|
||||
iY += $hEditor.Y
|
||||
hCont = $hEditor.Parent
|
||||
Do
|
||||
If hCont Is Form Then Break
|
||||
|
|
|
@ -750,7 +750,7 @@ Public Sub GetPosition() As Integer
|
|||
|
||||
End
|
||||
|
||||
Public Sub SetPosition(hResult As CFindResult, Optional bJustCheck As Boolean) As Boolean
|
||||
Public Sub SetPosition(hResult As CSearchResult, Optional bJustCheck As Boolean) As Boolean
|
||||
|
||||
Return $hEditor.SetPosition(hResult, bJustCheck)
|
||||
|
||||
|
|
|
@ -267,16 +267,13 @@ Public Sub Modify(Optional bReset As Boolean)
|
|||
|
||||
If Me.ReadOnly Then Return
|
||||
|
||||
$bModify = True
|
||||
Inc Project.TimeStamp
|
||||
Inc Age
|
||||
|
||||
FSearch.OnFileChange(Me.Path)
|
||||
FDebugInfo.RefreshTabs(Me.Path, Me.Name)
|
||||
|
||||
If bReset Then
|
||||
$bModify = False
|
||||
Endif
|
||||
$bModify = Not bReset
|
||||
If $bModify Then FSearch.OnFileChange(Me.Path)
|
||||
|
||||
DrawTitle
|
||||
|
||||
|
@ -3345,9 +3342,10 @@ Public Sub GetPosition() As Integer
|
|||
|
||||
End
|
||||
|
||||
Public Sub SetPosition(hResult As CFindResult, Optional bJustCheck As Boolean) As Boolean
|
||||
Public Sub SetPosition(hResult As CSearchResult, Optional bJustCheck As Boolean) As Boolean
|
||||
|
||||
Dim bResult As Boolean
|
||||
Dim sWhere As String
|
||||
|
||||
If FSearch.CurrentProcedure Then
|
||||
bResult = $hEditor.SetPosition(hResult, True)
|
||||
|
@ -3358,6 +3356,13 @@ Public Sub SetPosition(hResult As CFindResult, Optional bJustCheck As Boolean) A
|
|||
Else
|
||||
bResult = $hEditor.SetPosition(hResult, bJustCheck)
|
||||
Endif
|
||||
|
||||
If bJustCheck And If Not bResult Then
|
||||
sWhere = GetProcAt(hResult.Line)
|
||||
If Not sWhere Then sWhere = ("Declarations")
|
||||
hResult.Location = sWhere
|
||||
Endif
|
||||
|
||||
Return bResult
|
||||
|
||||
End
|
||||
|
|
|
@ -265,14 +265,11 @@ Public Sub Modify(Optional bReset As Boolean)
|
|||
|
||||
If Project.ReadOnly Then Return
|
||||
|
||||
$bModify = True
|
||||
Inc Project.TimeStamp
|
||||
Inc Age
|
||||
FSearch.OnFileChange(Me.Path)
|
||||
|
||||
If bReset Then
|
||||
$bModify = False
|
||||
Endif
|
||||
$bModify = Not bReset
|
||||
If $bModify Then FSearch.OnFileChange(Me.Path)
|
||||
|
||||
DrawTitle
|
||||
|
||||
|
@ -871,7 +868,11 @@ Public Sub GetPosition() As Integer
|
|||
|
||||
End
|
||||
|
||||
Public Sub SetPosition(hResult As CFindResult, Optional bJustCheck As Boolean) As Boolean
|
||||
Public Sub SetPosition(hResult As CSearchResult, Optional bJustCheck As Boolean) As Boolean
|
||||
|
||||
If bJustCheck Then
|
||||
hResult.Location = GetProcAt(hResult.Line)
|
||||
Endif
|
||||
|
||||
Return $hEditor.SetPosition(hResult, bJustCheck)
|
||||
|
||||
|
|
|
@ -1928,9 +1928,9 @@ Public Sub Modify(Optional bReset As Boolean)
|
|||
Inc Project.TimeStamp
|
||||
Inc Age
|
||||
|
||||
FSearch.OnFileChange(Me.Path)
|
||||
|
||||
$bModify = Not bReset
|
||||
If $bModify Then FSearch.OnFileChange(Me.Path)
|
||||
|
||||
DrawTitle
|
||||
|
||||
End
|
||||
|
@ -3752,15 +3752,15 @@ Public Sub GetPosition() As Integer
|
|||
|
||||
End
|
||||
|
||||
Public Sub SetPosition(hResult As CFindResult, Optional bJustCheck As Boolean) As Boolean
|
||||
Public Sub SetPosition(hResult As CSearchResult, Optional bJustCheck As Boolean) As Boolean
|
||||
|
||||
Dim sName As String = hResult.GetLocation()
|
||||
Dim aName As String[]
|
||||
|
||||
If bJustCheck Then
|
||||
If Not sName Then Return True
|
||||
FindLocation(hResult)
|
||||
If Not hResult.Location Then Return True
|
||||
Else
|
||||
aName = Split(sName, ".")
|
||||
aName = Split(hResult.Location, ".")
|
||||
Try SelectControl(aName[0])
|
||||
If Not Error Then FProperty.FocusOn(aName[1])
|
||||
Endif
|
||||
|
@ -4392,34 +4392,50 @@ Public Sub dwgInfo_Draw()
|
|||
|
||||
End
|
||||
|
||||
Public Sub GetLocation(iLine As Integer) As String
|
||||
Private Sub FindLocation(hResult As CSearchResult)
|
||||
|
||||
Dim aText As String[]
|
||||
Dim sLine As String
|
||||
Dim iPos As Integer
|
||||
Dim sProperty As String
|
||||
Dim iLevel As Integer
|
||||
Dim sText As String
|
||||
Dim iPos2 As Integer
|
||||
|
||||
aText = Split(GetText(), "\n")
|
||||
Dec iLine
|
||||
If iLine > aText.Max Then Return
|
||||
sLine = Trim(aText[iLine])
|
||||
iPos = InStr(sLine, " = ")
|
||||
If iPos = 0 Then Return
|
||||
sProperty = Left(sLine, iPos - 1)
|
||||
sText = GetText()
|
||||
|
||||
While iLine >= 0
|
||||
sLine = Trim(aText[iLine])
|
||||
iPos = RInStr(sText, "\n", hResult.Pos) + 1
|
||||
|
||||
iPos2 = InStr(sText, "\n", iPos + 1)
|
||||
If iPos2 = 0 Then iPos2 = Len(sText) + 1
|
||||
|
||||
sLine = Mid$(sText, iPos, iPos2 - iPos)
|
||||
|
||||
hResult.Column = hResult.Pos - iPos + 1
|
||||
hResult.Text = sLine
|
||||
|
||||
sLine = Trim(sLine)
|
||||
iPos2 = InStr(sLine, " = ")
|
||||
If iPos2 = 0 Then Return
|
||||
sProperty = Left(sLine, iPos2 - 1)
|
||||
|
||||
While iPos > 1
|
||||
iPos2 = iPos - 1
|
||||
If iPos = 2 Then
|
||||
iPos = 1
|
||||
Else
|
||||
iPos = RInStr(sText, "\n", iPos - 2) + 1
|
||||
Endif
|
||||
sLine = Trim(Mid$(sText, iPos, iPos2 - iPos))
|
||||
If sLine = "}" Then
|
||||
Inc iLevel
|
||||
Else If sLine Begins "{ " Then
|
||||
If iLevel Then
|
||||
Dec iLevel
|
||||
Else
|
||||
Return Split(sLine, " ")[1] & "." & sProperty
|
||||
hResult.Location = Split(sLine, " ")[1] & "." & sProperty
|
||||
Break
|
||||
Endif
|
||||
Endif
|
||||
Dec iLine
|
||||
Wend
|
||||
|
||||
End
|
||||
|
|
|
@ -12,13 +12,15 @@ Private $iEndColumn As Integer
|
|||
Private $hLabel As TextLabel
|
||||
Private $hLabelTimer As Timer
|
||||
Private $hObserver As Observer
|
||||
Private $iLastLine As Integer = -1
|
||||
|
||||
Private $bLabelBottom As Boolean
|
||||
|
||||
Static Private $sFindPrefix As String
|
||||
Static Private $aFind As Integer[]
|
||||
|
||||
Private $iLastLine As Integer
|
||||
Private $iLastLineOffset As Integer
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
$hObserver = New Observer(Me) As "Editor"
|
||||
|
@ -77,69 +79,56 @@ Public Sub GetPosition() As Integer
|
|||
|
||||
End
|
||||
|
||||
Fast Private Sub CalcPos(iPos As Integer) As Integer[]
|
||||
Fast Private Sub GetLineOffset(iLine As Integer) As Integer
|
||||
|
||||
Dim iLine As Integer
|
||||
Dim iLen As Integer
|
||||
Dim I As Integer
|
||||
Dim iOffset As Integer
|
||||
|
||||
While iLine < Me.Count
|
||||
|
||||
iLen = Len(Me[iLine].Text)
|
||||
If iPos <= iLen Then Break
|
||||
iPos -= iLen + 1
|
||||
Inc iLine
|
||||
If $iLastLine >= 0 And If iLine >= $iLastLine Then
|
||||
I = $iLastLine
|
||||
iOffset = $iLastLineOffset
|
||||
Endif
|
||||
|
||||
While I < iLine
|
||||
iOffset += Len(Me[I].Text) + 1
|
||||
Inc I
|
||||
Wend
|
||||
|
||||
Return [iLine, iPos]
|
||||
$iLastLine = iLine
|
||||
$iLastLineOffset = iOffset
|
||||
|
||||
Return iOffset
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub SetPosition(hFindResult As CFindResult, bJustCheck As Boolean) As Boolean
|
||||
Public Sub SetPosition(hResult As CSearchResult, bJustCheck As Boolean) As Boolean
|
||||
|
||||
Dim iLine, iColumn As Integer
|
||||
Dim sLine As String
|
||||
Dim iPos As Integer
|
||||
Dim aPos As Integer[]
|
||||
Dim iOffset As Integer
|
||||
|
||||
' If hFindResult.Line Or If hFindResult.Column Then
|
||||
'
|
||||
' iLine = hFindResult.Line
|
||||
' iColumn = hFindResult.Column
|
||||
' sLine = Me.Lines[iLine].Text
|
||||
'
|
||||
' Else
|
||||
|
||||
aPos = CalcPos(hFindResult.Pos)
|
||||
iLine = aPos[0]
|
||||
iPos = aPos[1]
|
||||
|
||||
If iLine >= Me.Count Then Return True
|
||||
|
||||
sLine = Me[iLine].Text
|
||||
iColumn = String.Len(Left$(sLine, iPos))
|
||||
|
||||
If Me.Highlight Then
|
||||
If InStr(String.Mid$(Me[iLine].Purge(Not FSearch.IgnoreComments, Not FSearch.IgnoreStrings, Chr$(1)), iColumn + 1, hFindResult.Length), Chr$(1)) Then Return True
|
||||
Endif
|
||||
|
||||
hFindResult.Line = iLine
|
||||
hFindResult.Column = iColumn
|
||||
iLine = hResult.Line - 1
|
||||
|
||||
If bJustCheck Then
|
||||
'If iColumn >= 40 And If Me[iLine].Length > 80 Then
|
||||
' sLine = "…" & Html(String.Mid$(sLine, iColumn - 31, 32)) & "<u>" & Html(String.Mid$(sLine, iColumn + 1, hFindResult.Length)) & "</u>" & Html(String.Mid$(sLine, iColumn + hFindResult.Length + 1, 160))
|
||||
'Else
|
||||
' sLine = Html(String.Left(sLine, iColumn)) & "<u>" & Html(String.Mid$(sLine, iColumn + 1, hFindResult.Length)) & "</u>" & Html(String.Mid$(sLine, iColumn + hFindResult.Length + 1, 160))
|
||||
'Endif
|
||||
'sLine = Replace(sLine, " ", " ")
|
||||
hFindResult.Text = sLine
|
||||
|
||||
iOffset = GetLineOffset(iLine)
|
||||
'If iLine >= Me.Count Then Return True
|
||||
|
||||
sLine = Me[iLine].Text
|
||||
iColumn = String.Len(Left$(sLine, hResult.Pos - iOffset))
|
||||
|
||||
If Me.Highlight Then
|
||||
If InStr(String.Mid$(Me[iLine].Purge(Not FSearch.IgnoreComments, Not FSearch.IgnoreStrings, Chr$(1)), iColumn + 1, hResult.Length), Chr$(1)) Then Return True
|
||||
Endif
|
||||
|
||||
hResult.Column = iColumn
|
||||
hResult.Text = sLine
|
||||
|
||||
Else
|
||||
' TODO Me[iLine].Expanded = True
|
||||
Me.GotoCenter(iColumn, iLine)
|
||||
Me.Goto(iColumn + hFindResult.Length, iLine, True)
|
||||
Me.GotoCenter(hResult.Column, iLine)
|
||||
Me.Goto(hResult.Column + hResult.Length, iLine, True)
|
||||
|
||||
Endif
|
||||
|
||||
End
|
||||
|
@ -286,7 +275,7 @@ End
|
|||
|
||||
Public Sub Editor_GotFocus()
|
||||
|
||||
$iLastLine = -1
|
||||
'$iLastLine = -1
|
||||
$aFind = Null
|
||||
$sFindPrefix = ""
|
||||
|
||||
|
@ -296,12 +285,12 @@ Public Sub Editor_Cursor()
|
|||
|
||||
HideMessageLabel
|
||||
|
||||
If Me.Line <> $iLastLine Then
|
||||
$iLastLine = Me.Line
|
||||
'$aFind = Null
|
||||
'$sFindPrefix = ""
|
||||
'Raise LineChange
|
||||
Endif
|
||||
' If Me.Line <> $iLastLine Then
|
||||
' $iLastLine = Me.Line
|
||||
' '$aFind = Null
|
||||
' '$sFindPrefix = ""
|
||||
' 'Raise LineChange
|
||||
' Endif
|
||||
|
||||
End
|
||||
|
||||
|
@ -475,3 +464,9 @@ Public Sub FillWithHistory(sPath As String)
|
|||
Dec Application.Busy
|
||||
|
||||
End
|
||||
|
||||
Public Sub Editor_Change()
|
||||
|
||||
$iLastLine = -1
|
||||
|
||||
End
|
||||
|
|
|
@ -31,7 +31,6 @@ Private $bFirstShowDebug As Boolean
|
|||
|
||||
Static Private $sCompressMessage As String
|
||||
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
'Me.ResizeScaled(86, 97)
|
||||
|
@ -1943,7 +1942,7 @@ Public Sub Form_KeyPress()
|
|||
If FSignature.VisibleFrom(hEditor.GetEditor()) Then Return
|
||||
Endif
|
||||
|
||||
If FSearch.InBrowse Then
|
||||
If FSearch.IsSearching() Then
|
||||
FSearch.Cancel
|
||||
Return
|
||||
Endif
|
||||
|
|
|
@ -1946,6 +1946,7 @@ Public Sub IsPatchFile(sPath As String) As Boolean
|
|||
Dim hFile As File
|
||||
Dim sHead As String
|
||||
|
||||
If Not IsTextFile(sPath) Then Return
|
||||
hFile = Open sPath
|
||||
sHead = Read #hFile, -4
|
||||
Return sHead = "diff"
|
||||
|
@ -1963,7 +1964,7 @@ Public Function LoadFile(sPath As String, Optional bNoErrorIfUnknown As Boolean)
|
|||
|
||||
If Not hForm Then
|
||||
|
||||
Inc Application.Busy
|
||||
'Inc Application.Busy
|
||||
|
||||
'If VersionControl.InConflict(sPath) Then Error.Raise("File in conflict")
|
||||
If IsConflict(sPath) Then
|
||||
|
@ -1994,7 +1995,7 @@ Public Function LoadFile(sPath As String, Optional bNoErrorIfUnknown As Boolean)
|
|||
Else If IsConnectionPath(sPath) Then
|
||||
|
||||
If MConnection.CheckPassword(sPath) Then
|
||||
Dec Application.Busy
|
||||
'Dec Application.Busy
|
||||
Return
|
||||
Endif
|
||||
hForm = New FConnectionEditor(sPath)
|
||||
|
@ -2019,7 +2020,7 @@ Public Function LoadFile(sPath As String, Optional bNoErrorIfUnknown As Boolean)
|
|||
|
||||
Else
|
||||
|
||||
Dec Application.Busy
|
||||
'Dec Application.Busy
|
||||
Files[sPath] = Null
|
||||
If bNoErrorIfUnknown Then
|
||||
$bFileIsUnknown = True
|
||||
|
@ -2042,7 +2043,7 @@ Public Function LoadFile(sPath As String, Optional bNoErrorIfUnknown As Boolean)
|
|||
If bError Then
|
||||
Files[sPath] = Null
|
||||
Try hForm.Delete
|
||||
Dec Application.Busy
|
||||
'Dec Application.Busy
|
||||
Return
|
||||
Endif
|
||||
hForm.Icon = GetFileIcon(sPath)
|
||||
|
@ -2050,7 +2051,7 @@ Public Function LoadFile(sPath As String, Optional bNoErrorIfUnknown As Boolean)
|
|||
|
||||
If hForm Then FSearch.OnNewForm(hForm)
|
||||
|
||||
Dec Application.Busy
|
||||
'Dec Application.Busy
|
||||
|
||||
Endif
|
||||
|
||||
|
@ -2060,7 +2061,7 @@ Catch
|
|||
|
||||
sErr = Error.Text & "\n" & Error.Backtrace.Join(" ")
|
||||
If hForm Then Try hForm.Delete
|
||||
Dec Application.Busy
|
||||
'Dec Application.Busy
|
||||
Try Files[sPath] = Null
|
||||
FMain.ShowError(("Cannot open file.") & "\n\n" & sErr, sPath)
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
' Gambas class file
|
||||
|
||||
Public Path As String
|
||||
Public (File) As String
|
||||
Public (Line) As Integer
|
||||
Public Pos As Integer
|
||||
Public Column As Integer
|
||||
Public Text As String
|
||||
Public Bytes As Integer
|
||||
Public Length As Integer
|
||||
Public Dark As Boolean
|
||||
Public Control As String
|
||||
Public {Property} As String
|
||||
Public (Highlight) As String
|
||||
Public RichText As String
|
||||
|
||||
Private $sWhere As String
|
||||
|
||||
Public Sub GetLocation() As String
|
||||
|
||||
Dim hFile As Object
|
||||
|
||||
If Not Project.IsSourcePath(Path) Then Return
|
||||
If $sWhere Then Return $sWhere
|
||||
|
||||
$sWhere = "-"
|
||||
Try hFile = Project.LoadFile(Path)
|
||||
If hFile Then
|
||||
If hFile Is FEditor Or If hFile Is FTextEditor Then
|
||||
$sWhere = hFile.GetProcAt({Line})
|
||||
Else If hFile Is FForm Then
|
||||
$sWhere = hFile.GetLocation({Line})
|
||||
Endif
|
||||
Endif
|
||||
Return $sWhere
|
||||
|
||||
End
|
|
@ -3,4 +3,4 @@
|
|||
Public Path As String
|
||||
Public Age As Integer
|
||||
Public Command As String
|
||||
Public Result As CFindResult[]
|
||||
Public Result As CSearchResult[]
|
||||
|
|
47
app/src/gambas3/.src/Search/CSearchResult.class
Normal file
|
@ -0,0 +1,47 @@
|
|||
' Gambas class file
|
||||
|
||||
Public Path As String
|
||||
Public (File) As String
|
||||
Public (Line) As Integer
|
||||
Public Pos As Integer
|
||||
Public Column As Integer
|
||||
Public Text As String
|
||||
Public Bytes As Integer
|
||||
Public Length As Integer
|
||||
Public Dark As Boolean
|
||||
Public Control As String
|
||||
Public {Property} As String
|
||||
Public (Highlight) As String
|
||||
Public RichText As String
|
||||
Public Location As String
|
||||
|
||||
'Private $sWhere As String
|
||||
|
||||
' Public Sub GetLocation() As String
|
||||
'
|
||||
' Dim hFile As Object
|
||||
' Dim sPath As String
|
||||
'
|
||||
' sPath = Project.Dir &/ Path
|
||||
'
|
||||
' If Not Project.IsSourcePath(sPath) Then Return
|
||||
' If $sWhere Then Return $sWhere
|
||||
'
|
||||
' $sWhere = "-"
|
||||
' Try hFile = Project.LoadFile(sPath)
|
||||
' If hFile Then
|
||||
' If hFile Is FEditor Or If hFile Is FTextEditor Then
|
||||
' $sWhere = hFile.GetProcAt({Line})
|
||||
' If Not $sWhere Then $sWhere = ("(Declarations)")
|
||||
' Else If hFile Is FForm Then
|
||||
' $sWhere = hFile.GetLocation({Line})
|
||||
' Endif
|
||||
' Endif
|
||||
' Return $sWhere
|
||||
'
|
||||
' Catch
|
||||
'
|
||||
' $sWhere = "?"
|
||||
' Return $sWhere
|
||||
'
|
||||
' End
|
|
@ -2,8 +2,255 @@
|
|||
|
||||
Inherits Task
|
||||
|
||||
Public Search As String
|
||||
|
||||
Public IgnoreCase As Boolean
|
||||
Public WordsOnly As Boolean
|
||||
Public RegularExpression As Boolean
|
||||
|
||||
Public Where As String
|
||||
Public Update As String[]
|
||||
|
||||
Public Const ALL_FILES As String = "*"
|
||||
Public Const SOURCE_FILES As String = "$"
|
||||
Public Const DATA_FILES As String = "@"
|
||||
|
||||
Private $aExt As String[] = ["jpg", "jpeg", "bmp", "gif", "png", "ico", "xpm", "tga", "gambas", "wav", "ogg", "mp3", "mp4", "avi", "webm"]
|
||||
|
||||
Public Sub Main()
|
||||
|
||||
Dim sDir As String
|
||||
Dim sFile As String
|
||||
Dim sPath As String
|
||||
Dim sName As String
|
||||
Dim sExt As String
|
||||
Dim aFile As String[]
|
||||
Dim aSort As String[]
|
||||
|
||||
Application.Priority = 10
|
||||
|
||||
If Update Then
|
||||
|
||||
sDir = ""
|
||||
aFile = Update
|
||||
|
||||
Else
|
||||
|
||||
Select Case Where
|
||||
|
||||
Case ALL_FILES, DATA_FILES
|
||||
sDir = Project.Dir
|
||||
|
||||
Case SOURCE_FILES
|
||||
sDir = Project.SourceDir
|
||||
|
||||
Case Else
|
||||
sDir = File.Dir(Where)
|
||||
aFile = [File.Name(Where)]
|
||||
|
||||
End Select
|
||||
|
||||
Endif
|
||||
|
||||
If Not aFile Then
|
||||
aFile = RDir(sDir).Sort(gb.Natural)
|
||||
aSort = New String[]
|
||||
For Each sPath In aFile
|
||||
aSort.Add(File.Name(sPath))
|
||||
Next
|
||||
aFile.SortUsing(aSort)
|
||||
Endif
|
||||
|
||||
For Each sFile In aFile
|
||||
|
||||
If Right(sFile) = "~" Then Continue
|
||||
|
||||
sPath = sDir &/ sFile
|
||||
|
||||
sFile = Mid$(sPath, Len(Project.Dir) + 1)
|
||||
If Left(sFile) = "/" Then sFile = Mid$(sFile, 2)
|
||||
|
||||
If Left(sFile) = "." And If sFile Not Begins ".public/" Then
|
||||
If Where = DATA_FILES Then Continue
|
||||
If sFile Not Begins ".src/" Then Continue
|
||||
Endif
|
||||
|
||||
If IsDir(sPath) Then Continue
|
||||
If InStr(sPath, "/.svn/") Then Continue
|
||||
|
||||
sExt = LCase(File.Ext(sFile))
|
||||
If $aExt.Exist(sExt) Then Continue
|
||||
|
||||
sName = File.Name(sPath)
|
||||
If sName Begins "core." Then Continue
|
||||
If sName Begins "vgcore." Then Continue
|
||||
If sName Begins "callgrind.out." Then Continue
|
||||
If sName Begins "cachegrind.out." Then Continue
|
||||
|
||||
If Not Project.IsTextFile(sPath) Then Continue
|
||||
|
||||
' TODO: If bReplace And If Not Access(sPath) Then Continue
|
||||
|
||||
Print "/" &/ Mid$(sPath, Len(Project.Dir) + 1)
|
||||
|
||||
' If sFile Begins ".src/" Then
|
||||
' FDebugInfo.SetSearchListInfo(sName)
|
||||
' Else
|
||||
' FDebugInfo.SetSearchListInfo(sFile)
|
||||
' Endif
|
||||
|
||||
GrepFile(sPath) ', bReplace)
|
||||
|
||||
'Debug sName
|
||||
Next
|
||||
|
||||
|
||||
End
|
||||
|
||||
Private Sub GrepQuote(sStr As String) As String
|
||||
|
||||
Dim I As Integer
|
||||
Dim sCar As String
|
||||
Dim sResult As String
|
||||
|
||||
For I = 1 To String.Len(sStr)
|
||||
sCar = String.Mid$(sStr, I, 1)
|
||||
If Len(sCar) > 1 Or If IsLetter(sCar) Or If IsDigit(sCar) Then
|
||||
sResult &= sCar
|
||||
Else
|
||||
sResult &= "\\" & sCar
|
||||
Endif
|
||||
Next
|
||||
|
||||
Return sResult
|
||||
|
||||
End
|
||||
|
||||
Private Sub GrepFile(sPath As String, Optional bUseReplaceString As Boolean)
|
||||
|
||||
Dim sText As String
|
||||
Dim aGrep As String[]
|
||||
Dim sGrep As String
|
||||
Dim sFind As String
|
||||
Dim sTemp As String
|
||||
' Dim iAge As Integer
|
||||
' Dim hGrepResult As CGrepResult
|
||||
Dim iPos As Integer
|
||||
Dim sSearch As String
|
||||
Dim hFile As Object
|
||||
Dim sResult As String
|
||||
Dim iFilePos As Integer
|
||||
|
||||
hFile = Project.Files[sPath]
|
||||
|
||||
If sPath Then
|
||||
If Not hFile Or If Not hFile.IsModified() Then
|
||||
sTemp = sPath
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If Not sTemp Then
|
||||
Try sText = hFile.GetText()
|
||||
If Error Then Return
|
||||
sTemp = Temp$("grep")
|
||||
File.Save(sTemp, sText)
|
||||
Endif
|
||||
|
||||
aGrep = ["grep", "-nobs"]
|
||||
|
||||
If bUseReplaceString Then
|
||||
' aGrep.Add("-F")
|
||||
' aGrep.Add("--")
|
||||
' aGrep.Add(ReplaceString)
|
||||
Else
|
||||
If IgnoreCase Then aGrep.Add("-i")
|
||||
If RegularExpression Then
|
||||
aGrep.Add("-E")
|
||||
Else If WordsOnly Then
|
||||
aGrep.Add("-E")
|
||||
Else
|
||||
aGrep.Add("-F")
|
||||
Endif
|
||||
aGrep.Add("--")
|
||||
|
||||
sSearch = Search
|
||||
If WordsOnly Then sSearch = "(^|[^_$[:alnum:]])" & GrepQuote(Search) & "($|[^_$[:alnum:]])"
|
||||
aGrep.Add(sSearch)
|
||||
Endif
|
||||
|
||||
aGrep.Add(sTemp)
|
||||
|
||||
' If sPath Then
|
||||
' hGrepResult = $cGrepCache[sPath]
|
||||
'
|
||||
' If hGrepResult Then
|
||||
' Try iAge = hFile.Age
|
||||
' If iAge = hGrepResult.Age Then
|
||||
' If aGrep.Join("\n") = hGrepResult.Command Then
|
||||
' Return hGrepResult.Result
|
||||
' Endif
|
||||
' Endif
|
||||
' Endif
|
||||
' Endif
|
||||
|
||||
'grep -nR -F -I -i -w -ob --exclude=*~ --exclude-dir=.svn -s -- "Date" * .src
|
||||
|
||||
Exec aGrep To sGrep
|
||||
|
||||
For Each sFind In Split(sGrep, "\n", "", True)
|
||||
|
||||
If hFile Then
|
||||
' If hFile Is FOutput Then
|
||||
' hResult.Path = ""
|
||||
' hResult.File = "Console"
|
||||
' Else
|
||||
'hResult.Path = sPath
|
||||
''hResult.File = hFile.Name
|
||||
'Endif
|
||||
Else
|
||||
'hResult.Path = sPath
|
||||
''hResult.File = If(Project.IsSourcePath(sPath), File.BaseName(sPath), File.Name(sPath))
|
||||
Endif
|
||||
|
||||
'hResult.Highlight = TextEditor.GetModeFromPath(sPath)
|
||||
|
||||
iPos = InStr(sFind, ":")
|
||||
If iPos = 0 Then Continue
|
||||
|
||||
sResult = CStr(CInt(Left(sFind, iPos - 1)))
|
||||
sFind = Mid$(sFind, iPos + 1)
|
||||
|
||||
iPos = InStr(sFind, ":")
|
||||
If iPos = 0 Then Continue
|
||||
|
||||
iFilePos = CInt(Left(sFind, iPos - 1))
|
||||
sFind = Mid$(sFind, iPos + 1)
|
||||
|
||||
If WordsOnly Then
|
||||
If String.Left(sFind) <> String.Left(Search) Then iFilePos += String.Len(String.Left(sFind))
|
||||
sFind = Search
|
||||
Endif
|
||||
|
||||
sResult &= ":" & CStr(iFilePos)
|
||||
|
||||
sResult &= ":" & CStr(Len(sFind)) & ":" & CStr(String.Len(sFind)) '& ":" & sFind
|
||||
Print sResult
|
||||
Flush
|
||||
'Sleep 0.005
|
||||
|
||||
Next
|
||||
|
||||
' If sPath Then
|
||||
' If hFile Then Try iAge = hFile.Age
|
||||
' hGrepResult = New CGrepResult
|
||||
' With hGrepResult
|
||||
' .Result = aResult.Copy()
|
||||
' .Age = iAge
|
||||
' .Path = sPath
|
||||
' .Command = aGrep.Join("\n")
|
||||
' End With
|
||||
' $cGrepCache[sPath] = hGrepResult
|
||||
' Endif
|
||||
|
||||
End
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
MoveScaled(0,3,25,4)
|
||||
Text = Shortcut(("Case sensitive"), "C")
|
||||
}
|
||||
{ chkWordOnly CheckBox
|
||||
{ chkWordsOnly CheckBox
|
||||
MoveScaled(0,6,25,4)
|
||||
Text = Shortcut(("Words only"), "W")
|
||||
}
|
||||
|
@ -90,7 +90,7 @@
|
|||
{ radCurrentProcedure RadioButton radSearch
|
||||
Name = "radCurrentProcedure"
|
||||
MoveScaled(0,4,25,4)
|
||||
Text = Shortcut(("Current procedure"), "u")
|
||||
Text = Shortcut(("Current function"), "u")
|
||||
}
|
||||
{ radCurrentFile RadioButton radSearch
|
||||
Name = "radCurrentFile"
|
||||
|
@ -146,11 +146,11 @@
|
|||
Picture = Picture["icon:/small/wizard"]
|
||||
}
|
||||
{ Panel1 Panel
|
||||
MoveScaled(7,22,3,3)
|
||||
MoveScaled(7,28,3,3)
|
||||
Expand = True
|
||||
}
|
||||
{ chkHighlight CheckBox
|
||||
MoveScaled(0,29,25,4)
|
||||
MoveScaled(0,30,25,4)
|
||||
Text = Shortcut(("Highlight search"), "H")
|
||||
}
|
||||
}
|
||||
|
@ -158,6 +158,10 @@
|
|||
#MoveScaled(53,2)
|
||||
Delay = 500
|
||||
}
|
||||
{ timFillList #Timer
|
||||
#MoveScaled(88,6)
|
||||
Delay = 100
|
||||
}
|
||||
}
|
||||
|
||||
# Gambas Action File 3.0
|
||||
|
|
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 594 B |
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 594 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 368 B |
Before Width: | Height: | Size: 459 B After Width: | Height: | Size: 368 B |
Before Width: | Height: | Size: 175 B After Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 483 B After Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 222 B |
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 222 B |
Before Width: | Height: | Size: 598 B After Width: | Height: | Size: 673 B |
Before Width: | Height: | Size: 637 B After Width: | Height: | Size: 673 B |
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 304 B |
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 304 B |