📄 feditor.class
字号:
ENDIF ENDIF ' Look for subroutines IF NOT bPoint THEN $hSymbol = CComponent.GetClassSymbols(".")[sSymbol] IF $hSymbol THEN RETURN $hSymbol.Type ENDIF ENDIF ' Look for static classes $bLastStatic = TRUE IF CComponent.Classes.Exist(sSymbol) THEN 'TRY $hSymbol = CComponent.GetClassSymbols(sSymbol)["_call"] RETURN sSymbol ENDIF ' Look for project classes IF Project.Exist(sSymbol) THEN IF Project.ExistForm(sSymbol) THEN $bLastStatic = FALSE RETURN sSymbol ENDIFENDPRIVATE SUB GetSymbolWith(aExpr AS String[], aType AS Integer[], OPTIONAL iInd AS Integer = -1) DIM iLine AS Integer DIM aWith AS String[] DIM aWithType AS Integer[] DIM iLevel AS Integer iLine = edtEditor.Line DO DEC iLine IF iLine < 0 THEN BREAK aWith = GambasEditor.Analyze(edtEditor.Lines[iLine]) IF aWith.Count >= 2 THEN IF aWith[0] = "WITH" THEN IF iLevel = 0 THEN aWithType = GambasEditor.Types aWith.Remove(0) aWithType.Remove(0) aExpr.Insert(aWith, iInd) aType.Insert(aWithType, iInd) RETURN ELSE DEC iLevel ENDIF ELSE IF aWith[0] = "END" THEN IF aWith[1] = "WITH" THEN INC iLevel ENDIF ENDIF ENDIF IF IsCurrentProc() THEN BREAK LOOPENDPRIVATE FUNCTION IsTypeSymbol(sPattern AS String, iType AS Integer) AS Boolean IF iType = Editor.Colors.Symbol THEN RETURN TRUE IF iType = Editor.Colors.DataType THEN RETURN TRUE IF iType = Editor.Colors.Function THEN RETURN TRUE IF iType = Editor.Colors.Keyword THEN IF sPattern = "ME" THEN RETURN TRUE IF sPattern = "LAST" THEN RETURN TRUE ENDIFENDPRIVATE FUNCTION GetExpressionType(aExpr AS String[], aType AS Integer[], bPointAfter AS Boolean) AS String DIM aWith AS String[] DIM iInd AS Integer DIM sWait AS NEW String[] DIM sPattern AS String DIM bLastSymbol AS Boolean DIM sType AS String DIM iType AS Integer DIM cSymbol AS Collection 'DIM hSymbol AS CSymbolInfo DIM bNeedMethod AS Boolean DIM bNeedArray AS Boolean DIM bFoundMethod AS Boolean $hSymbol = NULL '$bInMethod = 0 'IF aExpr.Count = 0 THEN RETURN iInd = aExpr.Count - 1 FOR iInd = iInd TO 0 STEP -1 sPattern = aExpr[iInd] IF sPattern = ")" THEN sWait.Push("(") bLastSymbol = FALSE CONTINUE ELSE IF sPattern = "]" THEN sWait.Push("[") bLastSymbol = FALSE CONTINUE ELSE IF sWait.Count THEN IF sPattern = sWait[sWait.Count - 1] THEN sWait.Pop ENDIF bLastSymbol = FALSE CONTINUE ELSE IF sPattern = "." THEN bLastSymbol = FALSE CONTINUE ELSE IF IsTypeSymbol(sPattern, aType[iInd]) THEN IF NOT bLastSymbol THEN bLastSymbol = TRUE CONTINUE ENDIF ENDIF BREAK NEXT sWait.Clear INC iInd IF iInd >= aExpr.Count THEN IF iInd > 0 THEN IF NOT bPointAfter THEN RETURN SELECT CASE aType[iInd - 1] CASE Editor.Colors.Operator, Editor.Colors.Keyword DEFAULT RETURN END SELECT ENDIF GetSymbolWith(aExpr, aType) 'PRINT "#1 WITH: "; aExpr.Join("/") ELSE IF aExpr[iInd] = "." THEN GetSymbolWith(aExpr, aType, iInd) 'PRINT "#2 WITH: "; aExpr.Join("/") ENDIF FOR iInd = iInd TO aExpr.Count - 1 sPattern = aExpr[iInd] 'PRINT sPattern IF sPattern = "(" THEN 'INC $bInMethod sWait.Push(")") CONTINUE ELSE IF sPattern = "[" THEN sWait.Push("]") CONTINUE ELSE IF sWait.Count THEN IF sPattern = sWait[sWait.Count - 1] THEN sWait.Pop IF sWait.Count THEN CONTINUE ELSE CONTINUE ENDIF ENDIF 'IF aType[iInd] = Editor.Colors.Symbol OR aType[iInd] = Editor.Colors.DataType OR aType[iInd] = Editor.Colors.Keyword THEN IF IsTypeSymbol(sPattern, aType[iInd]) THEN IF NOT sType THEN IF iInd >= (aExpr.Count - 1) THEN sType = GetSymbolType(sPattern, bPointAfter) ELSE sType = GetSymbolType(sPattern, aExpr[iInd + 1] = ".") ENDIF IF $hSymbol THEN '$bLastStatic = FALSE sType = $hSymbol.Type bNeedMethod = LCase($hSymbol.Kind) = "m" ENDIF ENDIF IF NOT sType THEN RETURN ELSE IF sPattern = "." THEN IF iInd <= (aExpr.Count - 2) THEN IF sType THEN IF aType[iInd + 1] = Editor.Colors.Symbol THEN 'PRINT sType; " "; cSymbol = CComponent.GetClassSymbols(sType) $hSymbol = NULL TRY $hSymbol = cSymbol[aExpr[iInd + 1]] IF NOT $hSymbol THEN RETURN sType = $hSymbol.Type $bLastStatic = FALSE ' A property cannot return static classes 'PRINT sType IF NOT sType THEN RETURN IF LCase($hSymbol.Kind) = "m" THEN bNeedMethod = TRUE INC iInd ELSE RETURN ENDIF ELSE RETURN ENDIF ELSE RETURN ENDIF ELSE IF sPattern = ")" THEN IF bNeedMethod THEN bNeedMethod = FALSE ELSE TRY $hSymbol = CComponent.GetClassSymbols(sType)["_call"] IF NOT $hSymbol THEN RETURN sType = $hSymbol.Type ''$bLastStatic = FALSE ENDIF ELSE IF sPattern = "]" THEN TRY $hSymbol = CComponent.GetClassSymbols(sType)["_get"] IF NOT $hSymbol THEN RETURN sType = $hSymbol.Type ''$bLastStatic = FALSE ENDIF NEXT IF bNeedMethod THEN RETURN RETURN sTypeENDPRIVATE SUB CheckCompletion() DIM sMode AS String DIM sLig AS String DIM sType AS String DIM aSymbols AS String[] DIM aTypes AS Integer[] IF NOT $bCompletion THEN RETURN 'IF Key.Code = Key.Backspace THEN ' IF FCompletion.IsMine(edtEditor) THEN ' sMode = Mid$(sLig, edtEditor.Column - 1, 1) ' ENDIF 'ELSE sMode = Key.Text 'ENDIF IF NOT sMode THEN RETURN sLig = Left$(edtEditor.PurgeLine(edtEditor.Line), edtEditor.Column) IF Right$(RTrim(sLig)) = "'" THEN RETURN IF sMode = " " THEN IF UCase(Right$(sLig, 3)) = " AS" OR UCase(Right$(sLig, 4)) = " NEW" THEN HideCompletion frmCompletion.Open() ENDIF ELSE IF sMode = "." THEN GambasEditor.Analyze(sLig & ".") aSymbols = GambasEditor.Symbols aTypes = GambasEditor.Types aSymbols.Remove(aSymbols.Count - 1) aTypes.Remove(aTypes.Count - 1) sType = GetExpressionType(aSymbols, aTypes, TRUE) IF sType THEN 'PRINT "Type: "; sType frmCompletion.Open(sType, $bLastStatic, LCase(sType) = LCase(ME.Name)) ENDIF ELSE HideCompletion ENDIFENDPRIVATE SUB HideCompletion() IF frmCompletion.Visible THEN 'PRINT "HideCompletion" frmCompletion.Hide ENDIFENDPRIVATE FUNCTION GetExpressionSignature(aExpr AS String[], aType AS Integer[]) AS CSymbolInfo DIM iInd AS Integer DIM sWait AS NEW String[] DIM sPattern AS String DIM sType AS String DIM bNew AS Boolean DIM hClass AS CClassInfo $hSymbol = NULL FOR iInd = aExpr.Count - 1 TO 0 STEP -1 sPattern = aExpr[iInd] IF sPattern = ")" THEN sWait.Push("(") 'bLastSymbol = FALSE CONTINUE ELSE IF sPattern = "]" THEN sWait.Push("[") 'bLastSymbol = FALSE CONTINUE ELSE IF sWait.Count THEN IF sPattern = sWait[sWait.Count - 1] THEN sWait.Pop ENDIF 'bLastSymbol = FALSE CONTINUE ELSE IF sPattern = "(" OR sPattern = "[" THEN BREAK ENDIF NEXT IF iInd < 1 THEN RETURN $iPosSignature = edtEditor.ToPosX(GambasEditor.Positions[iInd - 1]) IF iInd >= 2 THEN bNew = aExpr[iInd - 2] = "NEW" aExpr.Remove(iInd, -1) aType.Remove(iInd, -1) sType = GetExpressionType(aExpr, aType, FALSE) 'IF NOT $hSymbol THEN IF sPattern = "(" THEN IF bNew THEN TRY $hSymbol = CComponent.GetClassSymbols(sType)["_new"] ELSE TRY $hSymbol = CComponent.GetClassSymbols(sType)["_call"] ENDIF ELSE IF sPattern = "[" THEN TRY $hSymbol = CComponent.GetClassSymbols(sType)["_get"] ENDIF' IF $hSymbol THEN' IF $hSymbol.IsStatic() XOR $bLastStatic THEN' hClass = CComponent.Classes[$hSymbol.Component &/ $hSymbol.Class]' IF hClass THEN' IF NOT hClass.AutoCreatable THEN' $hSymbol = NULL' ENDIF' ELSE' $hSymbol = NULL' ENDIF' ENDIF' ENDIF 'ENDIF RETURN $hSymbolENDPRIVATE FUNCTION GetExpressionSymbol(aExpr AS String[], aType AS Integer[]) AS CSymbolInfo DIM iInd AS Integer DIM sWait AS NEW String[] DIM sPattern AS String DIM sType AS String DIM bNew AS Boolean DIM hClass AS CClassInfo $hSymbol = NULL IF aExpr.Count = 0 THEN RETURN sPattern = aExpr[aExpr.Count - 1] IF iInd >= 2 THEN bNew = aExpr[iInd - 2] = "NEW" IF Instr("[(", sPattern) THEN aType.Remove(aExpr.Count - 1) aExpr.Remove(aExpr.Count - 1) ENDIF sType = GetExpressionType(aExpr, aType, FALSE) 'IF NOT $hSymbol THEN IF sPattern = "(" THEN IF bNew THEN TRY $hSymbol = CComponent.GetClassSymbols(sType)["_new"] 'ELSE ' TRY $hSymbol = CComponent.GetClassSymbols(sType)["_call"] ENDIF 'ELSE IF sPattern = "[" THEN 'TRY $hSymbol = CComponent.GetClassSymbols(sType)["_get"] ENDIF' IF $hSymbol THEN' IF $hSymbol.IsStatic() XOR $bLastStatic THEN' hClass = CComponent.Classes[$hSymbol.Component &/ $hSymbol.Class]' IF hClass THEN' IF NOT hClass.AutoCreatable THEN' $hSymbol = NULL' ENDIF' ELSE' $hSymbol = NULL' ENDIF' ENDIF' ENDIF 'ENDIF RETURN $hSymbolENDPRIVATE SUB CheckSignature(OPTIONAL sText AS String) DIM sLig AS String DIM hSymbol AS CSymbolInfo IF NOT $bCompletion THEN RETURN sLig = Left$(edtEditor.PurgeLine(edtEditor.Line), edtEditor.Column) & sText GambasEditor.Analyze(sLig) IF NOT IsCurrentProc() THEN hSymbol = GetExpressionSignature(GambasEditor.Symbols, GambasEditor.Types) IF hSymbol THEN IF LCase(hSymbol.Kind) = "m" THEN frmSignature.Open($iPosSignature, hSymbol, NOT sText) ENDIF RETURN ENDIF ENDIF HideSignatureENDPRIVATE SUB HideSignature() frmSignature.HideENDPUBLIC SUB edtEditor_Scroll() 'PRINT "Scroll" HideCompletion HideSignatureENDPRIVATE SUB SetReadOnly() edtEditor.ReadOnly = Project.ReadOnly OR Project.Running UpdateMenuENDPRIVATE SUB Reload() DIM sText AS String sText = File.Load(Path) IF Right(sText) <> "\n" THEN sText = sText & "\n" edtEditor.Text = sText edtEditor.Reset edtEditor.SetFocus Modify(TRUE)ENDPUBLIC SUB mnuReload_Click() IF NOT IsModified() THEN RETURN IF Message.Warning(("The file has been modified.\n\nAll your changes will be lost."), ("Reload"), ("Cancel")) <> 1 THEN RETURN ReloadENDPRIVATE FUNCTION GetCurrentProcLine() AS Integer DIM iLine AS Integer iLine = edtEditor.Line DO IF IsProc(edtEditor.Lines[iLine]) THEN RETURN iLine DEC iLine IF iLine < 0 THEN RETURN -1 LOOPENDPUBLIC SUB btnIndent_Click() edtEditor.IndentENDPUBLIC SUB btnUnindent_Click() edtEditor.Indent(TRUE)ENDPRIVATE SUB FindDefinition() DIM sLig AS String DIM iCol AS Integer DIM hSymbol AS CSymbolInfo DIM iCpt AS Integer DIM sKeyword AS String DIM sKeyword2 AS String sLig = edtEditor.PurgeLine(edtEditor.Line) iCol = edtEditor.Column REPEAT INC iCol IF iCol > Len(sLig) THEN BREAK UNTIL Instr("ABCDEFGHIJKLMNOPQRSTUVWXYZ_$0123456789", UCase(Mid$(sLig, iCol, 1))) = 0 IF iCol < Len(sLig) THEN IF Instr("[(", Mid$(sLig, iCol, 1)) THEN INC iCol ENDIF ENDIF GambasEditor.Analyze(Left$(sLig, iCol - 1)) IF IsCurrentProc() THEN RETURN iCpt = GambasEditor.Types.Count - 1 IF iCpt >= 0 THEN IF GambasEditor.Types[iCpt] = Editor.Colors.Keyword THEN sKeyword = GambasEditor.Symbols[iCpt] IF iCpt > 0 THEN DEC iCpt IF GambasEditor.Types[iCpt] = Editor.Colors.Keyword THEN sKeyword2 = GambasEditor.Symbols[iCpt] & sKeyword ENDIF ENDIF FExplorer.GotoKeyword(sKeyword, sKeyword2) RETURN ENDIF ENDIF 'GambasEditor.Analyze(Left$(sLig, iCol - 1)) hSymbol = GetExpressionSymbol(GambasEditor.Symbols, GambasEditor.Types) IF NOT hSymbol THEN RETURN 'PRINT hSymbol.Class IF hSymbol.LineNumber THEN SavePosition() Project.OpenFile(hSymbol.Class, hSymbol.LineNumber) ELSE FExplorer.GotoSymbol(hSymbol) ENDIFENDPRIVATE SUB LastPosition() DIM aPos AS String[] DIM iPos AS Integer WITH Project.Positions IF .Count = 0 THEN RETURN aPos = Split(.Pop(), " ") IF aPos[0] = Path AND (Val(aPos[1]) = edtEditor.Line) AND (Val(aPos[2]) = edtEditor.Column) THEN LastPosition RETURN ENDIF 'PRINT "-> "; aPos.Join(" ") Project.OpenFile(aPos[0]) Project.Files[aPos[0]].GotoCenter(Val(aPos[1]) + 1, Val(aPos[2])) END WITHENDPRIVATE SUB SavePosition() Project.Positions.Push(Path & " " & edtEditor.Line & " " & edtEditor.Column) 'PRINT "Save: "; Project.Positions[Project.Positions.Count - 1]ENDPUBLIC SUB OnProjectDebug() SetReadOnlyEND
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -