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

📄 feditor.class

📁 Gambas is a graphical development environment based on a Basic interpreter, like Visual Basic. It us
💻 CLASS
📖 第 1 页 / 共 3 页
字号:
      FDebug.Stop      STOP EVENT    ENDIF  ELSE IF Key.Control THEN    IF Key.Code = Key["A"] THEN      mnuSelectAll_Click      STOP EVENT    ELSE IF Key.Code = Key.Up THEN      GotoPreviousProc      STOP EVENT    ELSE IF Key.Code = Key.Down THEN      GotoNextProc      STOP EVENT    ENDIF    RETURN  ENDIF  IF edtEditor.ReadOnly THEN RETURN  IF Asc(Key.Text) = 13 THEN    IF Key.Alt THEN      FMain.mnuProperty_Click    ELSE      sLine = Trim(edtEditor.Lines[iLine])      IF edtEditor.Column < Len(sLine) THEN RETURN      IF NOT IsProc(sLine) THEN RETURN      FOR iInd = iLine + 1 TO edtEditor.Lines.Count - 1        sLine = edtEditor.Lines[iInd]        IF IsEndProc(sLine) THEN RETURN        IF IsProc(sLine) THEN BREAK      NEXT      sLine = Trim(edtEditor.Lines[iLine])      IF Instr(sLine, "(") = 0 THEN edtEditor.Insert("()")      edtEditor.Insert("\n  \n  \n  \nEND\n")      edtEditor.Line = iLine + 2      edtEditor.Column = 2    ENDIF    'Key.Cancel = TRUE    STOP EVENT  ELSE IF Key.Code = Key.Space THEN    CheckCompletion    $bCheckSignature = TRUE  ELSE IF Key.Code = Key.Backspace THEN    'CheckCompletion    $bCheckSignature = TRUE  ELSE IF Key.Text = "." THEN    CheckCompletion  ELSE IF Instr("(),[]", Key.Text) THEN    $bCheckSignature = TRUE  ENDIFENDSTATIC PRIVATE FUNCTION IsCurrentProc() AS Boolean  DIM aLine AS String[]  DIM bProc AS Boolean  DIM iPos AS Integer  aLine = GambasEditor.Symbols  $bPublic = FALSE  $bStatic = FALSE  $sName = ""  FOR iPos = 0 TO aLine.Count - 1    IF aLine[iPos] = "PUBLIC" THEN      $bPublic = TRUE      CONTINUE    ENDIF    IF aLine[iPos] = "PRIVATE" THEN      $bPublic = FALSE      CONTINUE    ENDIF    IF aLine[iPos] = "STATIC" THEN      $bStatic = TRUE      CONTINUE    ENDIF    IF aLine[iPos] = "SUB" THEN      bProc = TRUE      BREAK    ENDIF    IF aLine[iPos] = "PROCEDURE" THEN      bProc = TRUE      BREAK    ENDIF    IF aLine[iPos] = "FUNCTION" THEN      bProc = TRUE      BREAK    ENDIF    BREAK  NEXT  IF bProc THEN    INC iPos    IF iPos >= aLine.Count THEN RETURN    $sName = aLine[iPos]  ENDIF  RETURN bProcENDSTATIC PUBLIC FUNCTION IsProc(sLine AS String) AS Boolean  GambasEditor.Analyze(sLine)  RETURN IsCurrentProc()ENDSTATIC PUBLIC FUNCTION IsEndProc(sLine AS String) AS Boolean  DIM iPos AS Integer  DIM iCommentPos AS Integer  sLine = UCase(Trim(sLine))  iCommentPos = Instr(sLine, "'")  IF iCommentPos > 0 THEN     sLine = Trim(Left$(sLine, iCommentPos - 1))  ENDIF  iPos = Instr(sLine, " ")  IF iPos = 0 THEN    RETURN sLine = "END"  ENDIF  IF Left$(sLine, iPos - 1) <> "END" THEN RETURN FALSE  sLine = Mid$(sLine, iPos + 1)  RETURN sLine = "PROCEDURE" OR sLine = "FUNCTION" OR sLine = "SUB"ENDPUBLIC SUB mnuFind_Click()  DIM sSel AS String  DIM iPos AS Integer  sSel = Left$(Trim(edtEditor.Selection.Text), 256)  iPos = Instr(sSel, gb.NewLine)  IF iPos THEN sSel = Left$(sSel, iPos - 1)  FFind.Find(sSel)ENDPUBLIC SUB mnuFindNext_Click()  FFind.FindNextENDPUBLIC SUB mnuFindPrevious_Click()  FFind.FindPreviousENDPUBLIC FUNCTION CanToggleBreakpoint(iLine AS Integer) AS Boolean  DIM sLine AS String  DIM iPos AS Integer  IF NOT edtEditor.Lines.GetFlag(iLine, GambasEditor.Breakpoint) THEN    sLine = Trim(edtEditor.Lines[iLine])    iPos = Instr(sLine , "'")    IF iPos THEN sLine = Trim(Left$(sLine, iPos - 1))    IF Len(Trim(sLine)) = 0 THEN RETURN FALSE    IF GetCurrentProcLine() < 0 THEN RETURN FALSE  ENDIF  RETURN TRUEENDPUBLIC SUB ToggleBreakpoint(iLine AS Integer)  DIM bOn AS Boolean  WITH edtEditor    bOn = .Lines.GetFlag(iLine, GambasEditor.Breakpoint)    .Lines.SetFlag(iLine, GambasEditor.Breakpoint, NOT bOn)  END WITHENDPUBLIC FUNCTION GetBreakpoints() AS Integer[]  DIM cBreak AS NEW Integer[]  DIM iLine AS Integer  DO    iLine = edtEditor.FindNextBreakpoint(iLine)    IF iLine < 0 THEN BREAK    cBreak.Add(iLine)    INC iLine  LOOP  'PRINT Name; ":"; cBreak.Count; " Breakpoint(s)"  RETURN cBreakENDPUBLIC SUB Rename(sNewName AS String, sNewPath AS String)  Name = sNewName  Path = sNewPath 'File.Dir(Path) &/ sNewName & "." & File.Ext(Path)  DrawTitleENDPRIVATE SUB StoreSelection()  WITH Editor    $iStartLine = .ToLine(.Selection.Start)    $iEndLine = .ToLine(.Selection.Start + .Selection.Length)    IF Editor.Column > 0 OR .Selection.Length = 0 THEN INC $iEndLine  END WITHENDPRIVATE SUB RecallSelection()  DIM iPos AS Integer  WITH Editor    iPos = .ToPos($iStartLine, 0)    Editor.Selection(iPos, Editor.ToPos($iEndLine, 0) - iPos)  END WITHENDPUBLIC SUB mnuComment_Click()  DIM iStart AS Integer  DIM iLength AS Integer  DIM iStartLine AS Integer  DIM iEndLine AS Integer  DIM iLine AS Integer  DIM sText AS String  IF edtEditor.ReadOnly THEN RETURN  StoreSelection  Editor.Frozen = TRUE  iStart = Editor.Selection.Start  iLength = Editor.Selection.Length  Editor.Pos = iStart  Editor.Select(Editor.ToPos(Editor.Line, 0), iLength + Editor.Column)  'sText = Editor.Selection.Text  'Editor.Selection.Text = "' " & Replace(Left$(sText, -1), gb.NewLine, gb.NewLine & "' ") & Right$(sText, 1)  FOR iLine = $iStartLine TO $iEndLine - 1    Editor.Lines[iLine] = "' " & Editor.Lines[iLine]  NEXT  'Modify  RecallSelection  Editor.Frozen = FALSEENDPUBLIC SUB mnuUncomment_Click()  DIM iStart AS Integer  DIM iLength AS Integer  DIM iBack AS Integer  DIM iLine AS Integer  DIM sLine AS String  IF edtEditor.ReadOnly THEN RETURN  StoreSelection  Editor.Frozen = TRUE  iStart = Editor.Selection.Start  iLength = Editor.Selection.Length  Editor.Pos = iStart  Editor.Select(Editor.ToPos(Editor.Line, 0), iLength + Editor.Column)  FOR iLine = $iStartLine TO $iEndLine - 1    sLine = Editor.Lines[iLine]    IF Left(sLine) <> "'" THEN BREAK    IF Len(sLine) = 1 THEN CONTINUE    IF Mid$(sLine, 2, 1) <> " " THEN BREAK  NEXT  IF iLine = $iEndLine THEN    FOR iLine = $iStartLine TO $iEndLine - 1      Editor.Lines[iLine] = Mid$(Editor.Lines[iLine], 3)    NEXT    'Modify  ENDIF  RecallSelection  Editor.Frozen = FALSEENDPUBLIC SUB mnuCut_Click()  Editor.CutENDPUBLIC SUB mnuCopy_Click()  Editor.CopyENDPUBLIC SUB mnuPaste_Click()  Editor.PasteENDPUBLIC SUB mnuUndo_Click()  Editor.UndoENDPUBLIC SUB mnuRedo_Click()  Editor.RedoENDPUBLIC SUB mnuForm_Click()  Project.OpenForm(Name)ENDPUBLIC SUB mnuWatch_Click()  DIM sWatch AS String  IF NOT Project.Running THEN RETURN  sWatch = Trim(edtEditor.Selection.Text)  IF NOT sWatch THEN RETURN  FDebugInfo.AddWatch(Trim(edtEditor.Selection.Text))ENDPUBLIC SUB mnuGotoLine_Click()  DIM iLine AS Integer  iLine = FGotoLine.Run(Editor.Line + 1)  IF iLine <= 0 THEN RETURN  GotoCenter(iLine)ENDPUBLIC SUB Form_Hide()  HideCompletion  Project.Deactivate(ME)ENDPUBLIC SUB mnuSelectAll_Click()  edtEditor.SelectionENDPRIVATE SUB GotoPreviousProc()  DIM iInd AS Integer  FOR iInd = Editor.Line - 2 TO 0 STEP -1    IF IsProc(edtEditor.Lines[iInd]) THEN      Editor.Line = iInd      Editor.Line = iInd + 1      RETURN    ENDIF  NEXT  Editor.Line = 0ENDPRIVATE SUB GotoNextProc()  DIM iInd AS Integer  FOR iInd = Editor.Line TO Editor.Lines.Count - 1    IF IsProc(edtEditor.Lines[iInd]) THEN      Editor.Line = iInd + 1      RETURN    ENDIF  NEXT  Editor.Line = Editor.Lines.Count - 1ENDPUBLIC SUB btnGoto_Click()  CreateMenu  mnuGoto.PopupENDPUBLIC SUB mnuBreakpoint_Click()  DIM iLine AS Integer  iLine = edtEditor.Line  IF CanToggleBreakpoint(iLine) THEN    IF NOT FDebug.ToggleBreakpoint(ME, iLine) THEN      ToggleBreakpoint(iLine)    ENDIF  ENDIFENDPUBLIC SUB mnuUntil_Click()  IF NOT CanToggleBreakpoint(edtEditor.Line) THEN RETURN  Project.RunUntil(ME, edtEditor.Line)ENDSTATIC PUBLIC FUNCTION ReadSymbolType(aSym AS String[], iIndex AS Integer, OPTIONAL sSymbol AS String) AS String  DIM sType AS String  IF sSymbol THEN    IF UCase(aSym[iIndex]) <> UCase(sSymbol) THEN RETURN    INC iIndex  ENDIF  IF aSym[iIndex] <> "AS" THEN RETURN  INC iIndex  IF aSym[iIndex] = "NEW" THEN INC iIndex  sType = aSym[iIndex]  IF $cType.Exist(sType) THEN sType = $cType[sType]  RETURN sTypeCATCHENDPRIVATE FUNCTION GetSymbolType(sSymbol AS String, OPTIONAL bPoint AS Boolean) AS String  DIM iLine AS Integer  DIM iInd AS Integer  DIM iPos AS Integer  DIM sParam AS String  DIM aSym AS String[]  DIM sType AS String  DIM sPath AS String  DIM hForm AS Object  'sSymbol = UCase(sSymbol)  $bLastStatic = FALSE  IF sSymbol = "ME" THEN RETURN Name  ' Look for local variables  iLine = edtEditor.Line  DO    DEC iLine    IF iLine < 0 THEN RETURN    aSym = GambasEditor.Analyze(edtEditor.Lines[iLine])    IF aSym.Count >= 1 THEN      IF asym.Count = 1 THEN        IF aSym[0] = "END" THEN BREAK      ENDIF      IF aSym.Count >= 4 THEN        IF aSym[0] = "DIM" THEN          sType = ReadSymbolType(aSym, 1, sSymbol)          IF sType THEN            WITH $hVirtualSymbol              .Name = aSym[1]              .Class = Name              .Kind = "v"              .LineNumber = iLine + 1              .NotPublic = TRUE              .Type = sType            END WITH            $hSymbol = $hVirtualSymbol            RETURN sType          ENDIF        ENDIF      ENDIF    ENDIF    IF IsCurrentProc() THEN BREAK  LOOP  ' Look for parameters  FOR iInd = 0 TO aSym.Count - 3    sType = ReadSymbolType(aSym, iInd, sSymbol)    IF sType THEN      WITH $hVirtualSymbol        .Name = aSym[0]        .Class = Name        .Kind = "v"        .LineNumber = iLine + 1        .NotPublic = TRUE        .Type = sType      END WITH      $hSymbol = $hVirtualSymbol      RETURN sType    ENDIF  NEXT  'IF UCase($sName) = UCase(sSymbol) THEN  '  GOTO RETURN_FUNCTION  'ENDIF  'PRINT "GetSymbolType: "; sSymbol  ' Look for private symbols  TRY $hSymbol = CComponent.GetClassSymbols(Name)[sSymbol]  IF NOT ERROR THEN    IF $hSymbol THEN      ' A private symbol that is a method cannot be followed by a point      ' So it must be a static class.      IF NOT ($hSymbol.Kind = "m" AND bPoint) THEN        ' This must be a private symbol, and so we must ignore inheritance        IF $hSymbol.Class = Name THEN        '$bLastStatic = $hSymbol.IsStatic()          RETURN $hSymbol.Type        ENDIF      ENDIF      $hSymbol = NULL

⌨️ 快捷键说明

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