Help browser: Add a search panel when help is offline.

[DEVELOPMENT ENVIRONMENT]
* NEW: Help browser: Add a search panel when help is offline.
This commit is contained in:
gambas 2021-06-19 02:21:54 +02:00
parent 1cc95c2353
commit 265643cdd5
8 changed files with 198 additions and 15 deletions

View file

@ -126,7 +126,7 @@ Public Sub SetMessage(Optional sText As String, bAdd As Boolean)
lblMessage.Text = $sMessage
lblMessage.Show
dwgStatus.Hide
Wait
If Project.NoWait = 0 Then Wait
Else
lblMessage.Hide
dwgStatus.Show

View file

@ -107,7 +107,7 @@ End
Public Sub Welcome()
frmWelcome.Show
frmWelcome.SetFocus
'frmWelcome.SetFocus
End

View file

@ -0,0 +1,47 @@
' Gambas class file
Inherits Task
Public Search As String
Public Buffer As String
Private $aImageExt As String[] = ["png", "jpg", "jpeg", "gif", "webm", "mov", "mp4", "mp3"]
Public Sub Main()
Dim aDir As New String[]
Dim sDir As String
Dim sData As String
Dim sRoot As String
Dim sFile As String
Dim sExt As String
Dim sLink As String
Application.Priority = 10
sRoot = MHelp.GetOfflineDir() &/ "data" &/ MHelp.GetLanguage()
aDir.Add(sRoot)
While aDir.Count
sDir = aDir.Pop()
Try sData = File.Load(sDir &/ "~page")
If Not Error Then
If String.InStr(sData, Search, 1, gb.IgnoreCase) Then
sLink = Mid$(sDir, Len(sRoot) + 1)
If Not sLink Then sLink = "/"
Print sLink
Flush
Endif
Endif
For Each sFile In Dir(sDir, "*", gb.Directory)
sExt = File.Ext(sFile)
If $aImageExt.Exist(sExt) Then Continue
aDir.Add(sDir &/ sFile, 0)
Next
Wend
End

View file

@ -8,6 +8,8 @@ Static Private $aLang As String[] = ["en", "fr", "de", "es", "it", "nl", "pl", "
Private $bPrint As Boolean
Private mnuLang As Menu
Private $bFirstTime As Boolean
Private $bOffline As Boolean
Private $hTask As CHelpSearchTask
Public Sub _new()
@ -50,7 +52,15 @@ End
Public Sub ReadConfig()
$bOffLine = Settings["/UseOfflineHelp"]
Project.SetSmallFont(panToolbar)
If $bOffLine Then
tabClass.ShowTabBar = True
Else
tabClass.ShowTabBar = False
tabClass.Index = 0
Endif
End
@ -200,7 +210,7 @@ End
Public Sub btnShowPanel_Click()
tvwClasses.Visible = btnShowPanel.Value
tabClass.Visible = btnShowPanel.Value
If btnShowPanel.Value Then FillTree
'If splHelp.Layout[0] = 0 Then splHelp.Layout = [1, 2]
@ -271,6 +281,7 @@ Public Sub tvwClasses_Select()
Dim aKey As String[]
Dim sKey As String
lstResult.UnSelectAll
sKey = tvwClasses.Current.Key
If Not sKey Or If sKey = "$" Then Return
@ -335,3 +346,88 @@ Public Sub OnProjectChange()
End
Public Sub tabClass_Click()
If tabClass.Index = 1 Then txtSearch.SetFocus
End
Public Sub btnSearch_Click()
Dim sText As String
If $hTask Then
$hTask.Stop
Else
sText = Trim(txtSearch.Text)
If sText Then
$hTask = New CHelpSearchTask As "TaskSearch"
$hTask.Search = sText
btnSearch.Picture = Picture["icon:/small/stop"]
txtSearch.Enabled = False
lstResult.Clear
spnSearch.Show
spnSearch.Raise
spnSearch.Start
Endif
Endif
End
Public Sub txtSearch_Activate()
btnSearch.Value = True
End
Public Sub TaskSearch_Read(Data As String)
Dim sLine As String
Dim iPos As Integer
Dim sTitle As String
Data = $hTask.Buffer & Data
iPos = RInStr(Data, "\n")
If iPos = 0 Then
$hTask.Buffer = Data
Return
Endif
$hTask.Buffer = Mid$(Data, iPos + 1)
Inc Project.NoWait
For Each sLine In Split(Left(Data, iPos - 1), "\n")
sTitle = Wiki.GetPageTitle(sLine)
If sTitle Then
lstResult.Add(sLine, sTitle)
Else
lstResult.Add(sLine, sLine).Foreground = Color.LightForeground
Endif
Next
Dec Project.NoWait
End
Public Sub TaskSearch_Kill()
$hTask = Null
btnSearch.Picture = Picture["icon:/small/find"]
txtSearch.Enabled = True
spnSearch.Hide
End
Public Sub lstResult_Select()
tvwClasses.UnSelectAll
MHelp.MakeOffline(webHelp, MHelp.GetURL(lstResult.Key))
End
Public Sub tabClass_Arrange()
spnSearch.Move(lstResult.X + (lstResult.W - spnSearch.W) \ 2, lstResult.Y + (lstResult.H - spnSearch.H) \ 2)
End

View file

@ -92,14 +92,53 @@
Arrangement = Arrange.Fill
{ splHelp HSplit
MoveScaled(2,2,80,29)
{ tvwClasses TreeView
MoveScaled(9,1,16,22)
Visible = False
Expand = True
{ tabClass TabPanel
MoveScaled(1,1,37,26)
Arrangement = Arrange.Vertical
Border = False
Count = 2
Index = 0
Text = ("Classes")
{ tvwClasses TreeView
MoveScaled(2,3,16,17)
Expand = True
Border = False
}
Index = 1
Text = ("Search")
{ Panel2 HBox
MoveScaled(0,1,34,4)
Background = Color.TextBackground
{ txtSearch ButtonBox
MoveScaled(0,0,24,4)
Expand = True
Border = False
Button = False
ClearButton = True
}
{ btnSearch ToolButton
MoveScaled(24,0,4,4)
Picture = Picture["icon:/small/find"]
}
}
{ Separator5 Separator
MoveScaled(7,7,14,0)
}
{ lstResult ListView
MoveScaled(3,11,25,10)
Expand = True
Border = False
}
{ spnSearch Spinner
MoveScaled(19,9,7,7)
Visible = False
Ignore = True
Type = Spinner.Circle
}
Index = 0
}
{ !webHelp HelpView
MoveScaled(29,1,28,16)
MoveScaled(45,4,28,16)
#Public = True
}
}

View file

@ -587,13 +587,12 @@ Public Sub GetSymbolTitle(Optional sPath As String) As String
If Not hSym And If sClass Ends "[]" Then
Try hSym = Documentation.Get(sComponent)["*[]"].Symbols[sSymbol]
Endif
If Not hSym Then Return sSymbol & " ?"
If InStr("e:", hSym.Kind) Then
Return Mid$(hSym.Name, 2)
Else
Return hSym.Name
Endif
Endif
' If Not hSym Then Return sSymbol & " ?"
' sName = hSym.Name
' If InStr("e:", hSym.Kind) Then sName = Mid$(sName, 2)
' Return hSym.Class & "." & sName & " (" & hSym.Component & ")"
' Endif
If Not hSym Then Return sClass & "." & sSymbol & " (" & sComponent & ")?"

View file

@ -599,7 +599,7 @@ Public Sub btnOfflineHelp_Click()
Settings["/UseOfflineHelp"] = btnOfflineHelp.Value
UpdateOfflineHelp
FHelpBrowser.GotoHome
FHelpBrowser.ReadConfig
End

View file

@ -232,6 +232,8 @@ Public UseInheritance As Boolean
Private $bFileIsUnknown As Boolean
Public NoWait As Integer
' If GetFileIcon() has been called on an added file
'Private $bLastAdded As Boolean