' Gambas module file

Property Read Highlighters As String[] Use $aHighlighter

Public Sub OnProjectChange()

  Dim sDir As String
  
  sDir = Project.Dir &/ ".conf"
  Analyze(sDir)
  
End

Private Sub Analyze(sDir As String)

  Dim sFile As String
  Dim sKey As String
  
  $aHighlighter = New String[]
  
  For Each sFile In RDir(sDir)
    If File.Ext(sFile) = "highlight" Then
      sKey = File.BaseName(sFile)
      Try TextHighlighter.Register(sKey,, sDir &/ sFile)
      If Error Then
        FMain.ShowErrorWith(Subst(("Unable to load custom highlighter <tt>&1</tt>"), Html(sFile)))
      Else
        $aHighlighter.Add(sKey)
      Endif
    Endif
  Next
  
  $aHighlighter.ReadOnly = True
  
End

Public Sub OnProjectClose()
  
End

Public Sub _put(vValue As Variant, sPath As String, sProperty As String)

  Dim cProp As Collection
  
  sPath = Project.MakeRelativePath(sPath)  
  cProp = Project.FileProperties[sPath]
  If Not cProp Then
    cProp = New Collection
    Project.FileProperties[sPath] = cProp
  Endif
  cProp[sProperty] = vValue
  If cProp.Count = 0 Then Project.FileProperties[sPath] = Null
  
End

Public Sub _get(sPath As String, sProperty As String) As Variant

  sPath = Project.MakeRelativePath(sPath)  
  Try Return Project.FileProperties[sPath][sProperty]
  
End

Public Sub HasProperty(sPath As String, sProperty As String) As Boolean
  
  sPath = Project.MakeRelativePath(sPath)  
  Try Return Project.FileProperties[sPath].Exist(sProperty)
  
End
