⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fexplorer.class

📁 Gambas is a graphical development environment based on a Basic interpreter, like Visual Basic. It us
💻 CLASS
字号:
' Gambas class fileSTATIC PRIVATE $cTypeName AS NEW CollectionPRIVATE $aBack AS NEW String[]PRIVATE $aForward AS NEW String[]PRIVATE $sHome AS StringPRIVATE $bShowHidden AS BooleanPRIVATE $aSearch AS NEW String[]STATIC PUBLIC SUB _init()  $cTypeName["b"] = "Boolean"  $cTypeName["c"] = "Byte"  $cTypeName["h"] = "Short"  $cTypeName["i"] = "Integer"  $cTypeName["d"] = "Date"  $cTypeName["f"] = "Float"  $cTypeName["v"] = "Variant"  $cTypeName["s"] = "String"  $cTypeName["o"] = "Object"ENDPUBLIC SUB _new()  Config.LoadWindow(ME, "/FExplorer")  splExplorer.Layout = Settings["/FExplorer/Splitter", "10, 20"]  $sHome = System.Path &/ "share/gambas/help/WebHome.html"  txvExplorer.Path = $sHome  FillTree  txvExplorer.SetFocusENDPUBLIC SUB splExplorer_Resize()  trvExplorer.Move(0, 0, tabExplorer.ClientW, tabExplorer.ClientH)  txtSearch.Move(0, 0, tabExplorer.ClientW)  lstSearch.Move(0, txtSearch.H, tabExplorer.ClientW, tabExplorer.ClientH - txtSearch.H)ENDPRIVATE FUNCTION GetType(sType AS String, bBalise AS Boolean) AS String  IF Len(sType) = 1 THEN    sType = $cTypeName[sType]  ELSE IF Left$(sType) = "." THEN    IF bBalise THEN      sType = "<I>" & Mid$(sType, 2) & "</I>"    ELSE      sType = "Object"    ENDIF  ENDIF  IF bBalise THEN    RETURN "<B>" & sType & "</B>"  ELSE    RETURN sType  ENDIFENDPUBLIC FUNCTION TransformSignature(sSign AS String, bBalise AS Boolean) AS String  iInd AS Integer  sRes AS String  sCar AS String  iPos AS Integer  bName AS Boolean  bFirst AS Boolean  DIM sBold AS String  DIM sNoBold AS String  IF bBalise THEN    sBold = "<B>"    sNoBold = "</B>"  ENDIF  bFirst = TRUE  DO    iInd = iInd + 1    IF iInd > Len(sSign) THEN BREAK    sCar = Mid$(sSign, iInd, 1)    IF sCar = "'" OR sCar = "(" THEN      IF sCar = "'" THEN        iPos = Instr(sSign, "'", iInd + 1)      ELSE        iPos = Instr(sSign, ")", iInd + 1)      ENDIF      IF iPos = 0 THEN BREAK      IF bFirst THEN        bFirst = FALSE      ELSE        sRes = sRes & sBold & "," & sNoBold & " "      ENDIF      sRes = sRes & Mid$(sSign, iInd + 1, iPos - iInd - 1) & " " & sBold & "AS" & sNoBold & " "      iInd = iPos      bName = TRUE      CONTINUE    ENDIF    IF sCar = "<" THEN      iPos = Instr(sSign, ">", iInd + 1)      IF iPos = 0 THEN BREAK      iInd = iPos      CONTINUE    ENDIF    IF sCar = "[" THEN      sRes = sRes & " " & sBold & "[" & sNoBold      CONTINUE    ENDIF    IF sCar = "]" THEN      sRes = sRes & " " & sBold & "] " & sNoBold      CONTINUE    ENDIF    IF NOT bName THEN      IF bFirst THEN        bFirst = FALSE      ELSE        sRes = sRes & sBold & "," & sNoBold & " "      ENDIF      sRes = sRes & sBold & "? AS " & sNoBold      bName = FALSE    ENDIF    IF sCar >= "A" AND sCar <= "Z" THEN      iPos = Instr(sSign, ";", iInd)      IF iPos = 0 THEN iPos = Len(sSign) + 1      sRes = sRes & Mid$(sSign, iInd, iPos - iInd)      iInd = iPos      CONTINUE    ENDIF    sRes = sRes & GetType(sCar, bBalise)  LOOP  RETURN sResEND' PUBLIC SUB txvExplorer_Link(Path AS String)''   GotoLink(Path)'' ENDPUBLIC SUB btnRefresh_Click()  txvExplorer.Path = txvExplorer.PathENDPRIVATE SUB MoveTo(sPath AS String)  DIM iPos AS Integer  DIM iY AS Integer  'PRINT "MoveTo: "; sPath  iPos = RInstr(sPath, "#")  IF iPos THEN    iY = Val(Mid$(sPath, iPos + 1))    sPath = Left$(sPath, iPos - 1)  ENDIF  txvExplorer.Path = sPath  txvExplorer.ScrollY = iYENDPRIVATE FUNCTION Where() AS String  'PRINT "Where: "; txvExplorer.Path & "#" & CStr(txvExplorer.ScrollY)  RETURN txvExplorer.Path & "#" & CStr(txvExplorer.ScrollY)ENDPUBLIC SUB btnBack_Click()  IF $aBack.Count = 0 THEN RETURN  $aForward.Push(Where())  MoveTo($aBack.Pop())ENDPUBLIC SUB btnForward_Click()  IF $aForward.Count = 0 THEN RETURN  $aBack.Push(Where())  MoveTo($aForward.Pop())ENDPUBLIC SUB btnHome_Click()  GotoLink($sHome)ENDPRIVATE SUB GotoLink(sLink AS String)  DIM sTemp AS String  DIM sText AS String  DIM iPos AS Integer  DIM sExec AS String  DIM bErr AS Boolean  DIM sPath AS String  IF sLink LIKE "http://*" THEN    Project.OpenWebPage(sLink)  ELSE    sPath = sLink    iPos = RInstr(sPath, "#")    IF iPos THEN sPath = Left(sPath, iPos - 1)    IF Exist(sPath) THEN      $aBack.Push(Where())      txvExplorer.Path = sLink      bErr = NOT txvExplorer.Text      $aForward.Clear    ELSE      bErr = TRUE    ENDIF    IF bErr THEN      'txvExplorer.Text = "<p><b>" & ("Broken link") & "</b><p>" & sLink      Message.Error(("The following link cannot be found:") & "\n\n" & sLink)    ENDIF  ENDIFCATCH  TRY txvExplorer.Text = Error.TextENDPUBLIC SUB Form_KeyPress()  SELECT Key.Code    CASE Key.Escape      ME.Close    CASE Key.BackSpace      btnBack_Click  END SELECTEND' PRIVATE SUB FillTreeWith(sLib AS String)''   DIM sClass AS String''   trvExplorer.Add(sLib, sLib, Picture["img/16/explorer.png"]).Expanded = TRUE''   FOR EACH sClass IN $cSymbol[sLib]''     'IF NOT $bShowHidden THEN'     '  IF Left$(sClass) = "." THEN'     '    CONTINUE'     '  ENDIF'     'ENDIF''     trvExplorer.Add(sLib &/ sClass, sClass, Picture["img/16/class.png"], sLib)'     trvExplorer.Add(sLib &/ sClass & "/", "", , sLib &/ sClass)''   NEXT'' ENDPRIVATE SUB FillTree()  DIM hComp AS CComponent  DIM sKey AS String  INC Application.Busy  sKey = "$"  trvExplorer.Add(sKey, "Gambas", Picture["img/16/gambas.png"])  trvExplorer.Add(sKey & "/", "", , sKey)  FOR EACH hComp IN CComponent.All    trvExplorer.Add(hComp.Key, hComp.Key, Picture["img/16/component.png"])    trvExplorer.Add(hComp.Key & "/", "", , hComp.Key)  NEXTFINALLY  DEC Application.BusyCATCH  Message.Error(("Cannot load help.") & "\n\n" & Error.Text)ENDPUBLIC SUB trvExplorer_Expand()  DIM iPos AS Integer  DIM aKey AS String[]  DIM hClass AS CClassInfo  DIM sClass AS String  DIM sKey AS String  DIM hSym AS CSymbolInfo  DIM sSymbol AS String  DIM aSymbol AS String[]  DIM sType AS String  DIM sIcon AS String  DIM sParent AS String  DIM aLang AS String[]  DIM sFile AS String  DIM sTitle AS String  sParent = LAST.Item.Key  trvExplorer.MoveChild()  IF trvExplorer.Item.Key <> sParent & "/" THEN RETURN  INC Application.Busy  trvExplorer.Remove(sParent & "/")  IF sParent = "$" THEN    Project.SetMessage(("Loading help..."))    aLang = Dir(File.Dir($sHome), "Lang*.html")    aLang.Sort    FOR EACH sFile IN aLang      sTitle = GetTitle(File.Load(File.Dir($sHome) &/ sFile))      IF NOT sTitle THEN CONTINUE 'sTitle = sFile      sFile = Mid$(File.Basename(sFile), 5)      trvExplorer.Add("$" &/ sFile, sTitle, Picture["img/16/gambas.png"], sParent)    NEXT    Project.SetMessage(("OK"))    DEC Application.Busy    RETURN  ENDIF  aKey = Split(sParent, "/")  IF aKey.Count = 1 THEN    WITH CComponent.All[sParent]      .Load      FOR EACH sClass IN .ClassList        IF Left(sClass)= "." THEN CONTINUE        sKey = sParent &/ sClass        IF CComponent.Classes[sKey].Properties THEN          sIcon = "img/16/control.png"        ELSE          sIcon = "img/16/class.png"        ENDIF        trvExplorer.Add(sKey, sClass, Picture[sIcon], sParent)        trvExplorer.Add(sKey & "/", "", , sKey)      NEXT    END WITH  ELSE IF aKey.Count = 2 THEN    hClass = CComponent.Classes[sParent]    aSymbol = NEW String[]    FOR EACH hSym IN hClass.Symbols      aSymbol.Add(hSym.Name)    NEXT    aSymbol.Sort(gb.Text)    FOR EACH sSymbol IN aSymbol      hSym = hClass.Symbols[sSymbol]      IF NOT $bShowHidden THEN        IF Left$(sSymbol) = "_" THEN          CONTINUE        ENDIF      ENDIF      sType = hSym.Kind      IF sType = ":" THEN        sKey = sParent &/ sSymbol        sSymbol = Mid$(sSymbol, 2)      ELSE        sKey = sParent &/ UCase(sType) & sSymbol      ENDIF      sIcon = hSym.GetIcon()      trvExplorer.Add(sKey, sSymbol, Picture[sIcon], sParent)    NEXT  ENDIF  DEC Application.BusyCATCH  DEC Application.Busy  Message.Error(("Cannot load help.") & "\n\n" & Error.Text)ENDPUBLIC SUB trvExplorer_Select()  DIM sKey AS String  DIM aKey AS String[]  DIM sLink AS String  DIM aComp AS String[]  DIM sComp AS String  sKey = LAST.Key  'PRINT sKey  aKey = Split(sKey, "/")  IF aKey.Count >= 1 THEN    IF aKey[0] = "$" THEN      IF aKey.Count >= 2 THEN        sLink = "Lang" & aKey[1]      ELSE        sLink = "WebHome"      ENDIF      sLink = File.Dir($sHome) &/ sLink & ".html"    ELSE      DO        sLink = ""        aComp = Split(aKey[0], ".")        FOR EACH sComp IN aComp          sLink = sLink & UCase(Left$(sComp)) & LCase(Mid$(sComp, 2))        NEXT        IF aKey.Count >= 2 THEN          sComp = Replace(aKey[1], ".", "")          'IF Left$(sComp) = "." THEN sComp = Mid$(sComp, 2)          sComp = UCase(Left$(sComp)) & Mid$(sComp, 2)          sLink = sLink & Replace(sComp, "[]", "Array")          IF aKey.Count = 3 THEN            sComp = Mid$(aKey[2], 2)            SELECT CASE Left$(aKey[2])              CASE ":"                sLink = sLink & "E" & sComp              CASE ELSE                sLink = sLink & Left$(aKey[2]) & sComp            END SELECT          ENDIF        ENDIF        IF Right$(sLink) = "$" THEN sLink = Left$(sLink, -1)        sLink = File.Dir($sHome) &/ sLink & ".html"        IF Exist(sLink) THEN BREAK        IF aKey.Count = 1 THEN BREAK        WITH CComponent.Classes[aKey[0] &/ aKey[1]]          aKey[0] = .ParentComponent          aKey[1] = .Parent        END WITH        IF NOT aKey[1] THEN BREAK      LOOP    ENDIF    GotoLink(sLink)  ENDIFENDPUBLIC SUB Form_Close()  Config.SaveWindow(ME, "/FExplorer")  Settings["/FExplorer/Splitter"] = splExplorer.LayoutENDPUBLIC SUB tabExplorer_Click()  IF tabExplorer.Index = 1 THEN txtSearch.SetFocusENDPRIVATE FUNCTION GetTitle(sData AS String) AS String  DIM iPos AS Integer  DIM iPos2 AS Integer  DIM sTitle AS String  DIM sEnd AS String  iPos = Instr(sData, "<h1><a name=")  sEnd = "</h1>"  IF iPos = 0 THEN    iPos = Instr(sData, "<h2><a name=")    sEnd = "</h2>"  ENDIF  IF iPos = 0 THEN RETURN  iPos2 = Instr(sData, sEnd, iPos + 7)  IF iPos2 = 0 THEN RETURN  sTitle = Trim(Mid$(sData, iPos, iPos2 - iPos))  DO    iPos = Instr(sTitle, "<")    IF iPos = 0 THEN BREAK    iPos2 = Instr(sTitle, ">", iPos + 1)    IF iPos2 = 0 THEN BREAK    sTitle = Left$(sTitle, iPos - 1) & Mid$(sTitle, iPos2 + 1)  LOOP  RETURN Trim(Replace(sTitle, "&nbsp;", ""))ENDPUBLIC SUB txtSearch_Activate()  DIM aTerm AS String[]  DIM sSearch AS String  DIM sFile AS String  DIM sData AS String  DIM sTitle AS String  DIM iPos AS Integer  DIM bFound AS Boolean  sSearch = Trim(LAST.Text)  IF NOT sSearch THEN RETURN  INC Application.Busy  $aSearch.Clear  aTerm = Split(UCase(sSearch), " ", Chr$(34))  lstSearch.Clear  FOR EACH sFile IN Dir(File.Dir($sHome), "*.html")    sData = File.Load(File.Dir($sHome) &/ sFile)    iPos = Instr(sData, "</head>")    IF iPos THEN iPos = iPos + 6    INC iPos    sTitle = GetTitle(Mid$(sData, iPos))    IF NOT sTitle THEN sTitle = File.BaseName(sFile)    sData = UCase(Mid$(sData, iPos))    FOR EACH sSearch IN aTerm      IF Instr(sData, sSearch) = 0 THEN        'sSearch = Replace(sSearch, "\\", "\\\\")        'sSearch = Replace(sSearch, "[", "\\[")        'sSearch = Replace(sSearch, "]", "\\[")        bFound = FALSE        TRY bFound = sData LIKE sSearch        IF NOT bFound THEN GOTO SUIVANT      ENDIF    NEXT    lstSearch.Add($aSearch.Count, sTitle)    $aSearch.Add(sFile)SUIVANT:  NEXT  DEC Application.BusyENDPUBLIC SUB lstSearch_Click()  GotoLink(File.Dir($sHome) &/ $aSearch[Val(lstSearch.Key)])ENDPUBLIC SUB trvExplorer_KeyPress()  Form_KeyPressEND' PUBLIC SUB txvExplorer_KeyPress()''   Form_KeyPress'' ENDPUBLIC FUNCTION GotoKeyword(sName AS String, OPTIONAL sName2 AS String) AS Boolean  DIM sKey AS String  DIM sText AS String  IF sName2 THEN    IF NOT GotoKeyword(sName2) THEN RETURN  ENDIF  IF Right(sName) = "$" THEN sName = Left$(sName, -1)  trvExplorer["$"].Expanded = TRUE  sKey = "$" &/ sName  IF NOT trvExplorer.Exist(sKey) THEN    trvExplorer.MoveTo("$")    trvExplorer.MoveChild    WHILE trvExplorer.Available      sText = UCase(trvExplorer.Item.Text)      IF sText <> trvExplorer.Item.Text THEN        IF Instr(sText, UCase(sName)) THEN          sKey = trvExplorer.Item.Key          BREAK        ENDIF      ENDIF      trvExplorer.MoveNext    WEND    IF NOT sKey THEN RETURN  ENDIF  trvExplorer["$"].Expanded = TRUE  trvExplorer["$"].EnsureVisible  trvExplorer[sKey].Selected = TRUE  trvExplorer[sKey].EnsureVisible  ME.ShowCATCH  RETURN TRUEENDPUBLIC SUB GotoSymbol(hSymbol AS CSymbolInfo)  DIM sComp AS String  DIM sClass AS String  DIM sName AS String  DIM sText AS String  DIM sKey AS String  DIM sKind AS String  sComp = hSymbol.Component  sClass = hSymbol.Class  sName = hSymbol.Name  IF sClass = "." THEN    sComp = "$"    sClass = ""    GotoKeyword(sName)  ELSE    IF Left(sName) = "_" THEN      sName = ""    ELSE      sName = UCase(hSymbol.Kind) & sName    ENDIF    sKey = sComp &/ sClass &/ sName    'PRINT sKey    WITH trvExplorer[sComp]      .EnsureVisible      .Expanded = TRUE    END WITH    IF sName THEN      WITH trvExplorer[sComp &/ sClass]        .EnsureVisible        .Expanded = TRUE      END WITH    ENDIF    IF NOT trvExplorer.Exist(sKey) THEN RETURN    WITH trvExplorer[sKey]      .Selected = TRUE      .EnsureVisible    END WITH    ME.Show  ENDIFCATCHENDPUBLIC SUB txvExplorer_Link(Path AS String)  GotoLink(Path)ENDPUBLIC SUB txvExplorer_KeyPress()  Form_KeyPressEND

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -