[Gambas-devel] Find your sub easier full function version
Yizhou He
yizhou_he at ...143...
Thu Aug 5 22:32:22 CEST 2004
Hi:
I didn't expect I can slove the problem so fast, I guess I'm warmed
up for Gambas. This version is report all the change compare to
Gambas 0.96, I think I reach the goal I wanted. Sorry for release
so many path in one day. Is there anyway to delete my previous two
message about this?
Yizhou He
'-------Modify sub in class FEditor----------
PUBLIC SUB Form_Activate()
Project.Activate(ME)
'edtEditor.SetFocus
'-------Yizhou He Start----------------
createmenu
'-------Yizhou He End----------------
END
'-------Modify sub in class FForm----------
PUBLIC SUB Form_Activate()
$bDoNotModify = FALSE
Project.Activate(ME)
'FProperty.Show
'FToolBox.Show
'-------Yizhou He Start----------------
createmenu
'-------Yizhou He Ended----------------
END
'------- add sub in class FMain---------
PUBLIC SUB AddMethod(sClass AS String,sItemName AS String,sPicture
AS String,OPTIONAL iLine AS Integer)
IF NOT tvwProject.exist(sClass & ":" & sItemName & "@" & iLine )
THEN tvwProject.add(sClass & ":" & sItemName & "@" &
iLine,sItemName,picture[sPicture],sClass)
tvwProject.current.Expanded=TRUE
END
'------- Modify sub in class FMain----
PUBLIC SUB tvwProject_Activate()
DIM iAtPos AS Integer
DIM sLineNumber AS String
DIM sLineString AS String
IF tvwProject.Key THEN
IF CanEdit(tvwProject.Key) THEN
iAtPos=Instr(tvwProject.Key,":")
IF iAtPos=0 THEN
sLineNumber="0"
sLineString=tvwProject.Key
ELSE
sLineNumber=Right(tvwProject.Key,Len(tvwproject.Key)-Instr(tvwProject.Key,"@"))
IF sLineNumber="0" THEN
sLineNumber=Mid(tvwProject.Key,Instr(tvwProject.Key,":")+1,Instr(tvwProject.Key,"@")-Instr(tvwProject.Key,":")-1)
sLineString=Left(tvwProject.Key,Instr(tvwProject.Key,":")-1)
ENDIF
Project.OpenFile(sLineString,sLineNumber)
ENDIF
ENDIF
END
'------- Modify sub in class FForm----
PUBLIC FUNCTION Save() AS Boolean
DIM hFic AS File
'-------Yizhou He Start----------------
createmenu
'-------Yizhou He Ended----------------
IF Project.ReadOnly THEN RETURN
IF NOT $bModify THEN RETURN
UnselectAll
Save.Begin(Path)
ResetSave
AddLine(Project.FORM_MAGIC)
AddLine()
SaveOne(Control[Name])
File.Save(Path, $sSave)
'OPEN Path & ".test" FOR CREATE AS #hFic ' y a un truc bizarre
avec CREATE !
'PRINT #hFic, $sSave
'CLOSE #hFic
$sSave = ""
$bModify = FALSE
DrawTitle
Save.End()
CATCH
RETURN Save.Error()
END
'--------- Modify sub in class FEditor -----------
PUBLIC FUNCTION Save() AS Boolean
DIM iLig AS Integer
DIM iProc AS Integer
DIM iFull AS Integer
DIM sLig AS String
DIM iPosProc AS Integer
DIM sData AS String
DIM iLine AS Integer
DIM iCol AS Integer
DIM bChange AS Boolean
DIM iCount AS Integer
DIM iVoidLine AS Integer
CreateMenu()
IF Project.ReadOnly THEN RETURN
IF NOT $bModify THEN RETURN
Save.Begin(Path)
IF $bCleanOnSave THEN
iProc = -1
iLine = edtEditor.Line
iCol = edtEditor.Column
iCount = edtEditor.Lines.Count
FOR iLig = 0 TO iCount
IF iLig < iCount THEN
sLig = RTrim(edtEditor.Lines[iLig])
ELSE
sLig = "SUB gambas()"
ENDIF
IF NOT LTrim(sLig) THEN
INC iVoidLine
CONTINUE
ENDIF
IF IsProc(sLig) THEN
IF iProc >= 0 THEN
IF iFull < 2 THEN
bChange = TRUE
sData = Left(sData, iPosProc)
IF iLine > iProc THEN
IF iLine < iLig THEN
iLine = iProc - 1
ELSE
iLine = iLine - (iLig - iProc + 1)
ENDIF
ENDIF
ENDIF
ENDIF
iProc = iLig
iFull = 0
iPosProc = Len(sData)
ELSE
INC iFull
ENDIF
IF iLig < iCount THEN
sData = sData & String(iVoidLine, "\n") & sLig & "\n"
iVoidLine = 0
ENDIF
NEXT
IF Len(sData) <> Len(edtEditor.Text) THEN
File.Save(Path, sData)
edtEditor.Frozen = TRUE
edtEditor.Text = sData
TRY edtEditor.Line = iLine
IF Error = 0 THEN
TRY edtEditor.Column = iCol
ENDIF
edtEditor.Frozen = FALSE
ENDIF
ENDIF
IF NOT bChange THEN File.Save(Path, edtEditor.Text)
$bModify = FALSE
DrawTitle
Save.End()
CATCH
RETURN Save.Error()
END
'-------- Modify sub in class FEditor -----------
PUBLIC SUB Goto(iLine AS Integer, OPTIONAL iColumn AS Integer = -1)
DIM iPosEOL AS Integer
DIM iposSOL AS Integer
edtEditor.Line=iLine
edtEditor.Column=0
iPosEOL=edtEditor.Pos
edtEditor.Line = iLine - 1
iPosSOL=edtEditor.Pos
IF iColumn >= 0 THEN
edtEditor.Column = iColumn
ELSE
edtEditor.Select(iPosSOL,iPosEOL-iPosSOL-1)
ENDIF
END
'-------- Add sub in class FForm -----------
PUBLIC SUB Goto(sCtrl AS String)
DIM hCtrl AS CControl
DIM sName AS String
createmenu
FOR EACH hCtrl IN Control
sName = hCtrl.Name
IF sName =sCtrl THEN
hCtrl.Select(ME)
FProperty.Refreshall
'hCtrl.Selected=TRUE
ELSE
hCtrl.UnSelect(ME)
ENDIF
NEXT
END
'------- Modify sub in class FEditor ----------
PRIVATE SUB CreateMenu()
DIM iInd AS Integer
DIM sLine AS String
DIM sName AS String
DIM hMenu AS Menu
DIM cFunc AS NEW String[]
DIM sParent AS String
DIM sNewParent AS String
DIM hParent AS Menu
DIM sFullName AS String
DIM sDesc AS String
DIM iPos AS Integer
'IF $hMenuGo THEN $hMenuGo.Delete
'$hMenuGo = NEW Menu(mnuEditor)
'$hMenuGo.Caption = "&Go to"
INC Application.Busy
mnuGoto.Children.Clear
$cLine.Clear
FOR iInd = 0 TO edtEditor.Lines.Count - 1
'sLine = edtEditor.Lines[iInd]
'PRINT sLine
IF IsProc(edtEditor.Lines[iInd]) THEN
IF NOT $cLine.Exist($sName) THEN
'PRINT $sName
'IF $bPublic THEN $sName = "#" & $sName
$cLine[$sName] = iInd
cFunc.Add($sName)
ENDIF
ENDIF
NEXT
cFunc.Sort(gb.Text)
hParent = mnuGoto
'-------Yizhou He Start-------
project.ProjectTree[Path].Clear
'-------Yizhou He Ended-------
FOR EACH sName IN cFunc
'IF Left$(sName) = "#" THEN
' sName = Mid$(sName, 2)
' $bPublic = TRUE
'ELSE
' $bPublic = FALSE
'ENDIF
sFullName = sName
iPos = Instr(sName, "_")
IF iPos THEN
sNewParent = Left$(sName, iPos - 1)
sName = Mid$(sName, iPos + 1)
IF Len(sNewParent) = 0 THEN
sNewParent = "(Special)"
sName = "_" & sName
ENDIF
ELSE
sNewParent = ""
ENDIF
IF UCase(sNewParent) <> UCase(sParent) THEN
IF sNewParent THEN
hParent = NEW Menu(mnuGoto)
hParent.Text = sNewParent
ELSE
hParent = mnuGoto
ENDIF
sParent = sNewParent
ENDIF
hMenu = NEW Menu(hParent) AS "mnuGoto"
hMenu.Text = sName
hMenu.Tag = sFullName
hMenu.Checked = $bPublic
'-------Yizhou He Start-------
IF Instr(sFullName,"_") THEN
fmain.AddMethod(Path,sFullName,"img/16/event.png",
$cLine[sFullName]+1)
ELSE
fmain.AddMethod(Path,sFullName,"img/16/method.png",
$cLine[sFullName]+1)
ENDIF
'-------Yizhou He Ended--------
NEXT
mnuGoto.Visible = $cLine.count > 0
mnuSepGoto.Visible = $cLine.count > 0
'mnuWatch.Visible = Project.Running
mnuWatch.Enabled = Project.Running AND
Len(Trim(edtEditor.Selection.Text)) > 0
'btnWatch.Enabled = mnuWatch
'mnuSepWatch.Visible = Project.Running
DEC Application.Busy
END
'----------Modified sub in class FForm--------
PRIVATE SUB CreateMenu()
DIM hCtrl AS CControl
DIM hMenu AS Menu
DIM cCtrl AS NEW String[]
DIM sName AS String
DIM cSymbol AS Collection
DIM hSymbol AS CSymbolInfo
DIM sGroup AS String
mnuSelect.Children.Clear
FOR EACH hCtrl IN Control
sName = hCtrl.Name
IF sName <> Name THEN
IF hCtrl.Kind <> "Menu" THEN
cCtrl.Add(sName)
ENDIF
ENDIF
NEXT
mnuSelect.Enabled = cCtrl.Count
cCtrl.Sort(gb.Text)
'-----------Yizhou He Start-------
project.ProjectTree[Path].Clear
'-----------Yizhou He Ended-------
FOR EACH sName IN cCtrl
hMenu = NEW Menu(mnuSelect) AS "mnuControl"
hMenu.Text = sName
'-------Yizhou He Start-----------------
fmain.AddMethod(Path,sName,"img/16/control.png")
'-------Yizhou He Ended------------------------------
NEXT
mnuEvent.Visible = FALSE
IF NOT $bReadOnly THEN
IF Master THEN
cCtrl = CComponent.Classes[Master.Kind].Events
sGroup = Master.GetGroup()
ELSE
cCtrl = CComponent.Classes["Form"].Events
sGroup = "Form"
ENDIF
IF cCtrl THEN
mnuEvent.Children.Clear
cSymbol = CComponent.GetClassSymbols(Name)
FOR EACH sName IN cCtrl
hMenu = NEW Menu(mnuEvent) AS "mnuEvent"
hMenu.Text = sName
hSymbol = cSymbol[sGroup & "_" & sName]
IF hSymbol THEN
IF hSymbol.Kind = "m" THEN hMenu.Checked = TRUE
ENDIF
NEXT
mnuEvent.Visible = TRUE
ENDIF
ENDIF
RefreshMenu
END
'-------- Modified sub in model Project--------
PUBLIC SUB OpenFile(sPath AS String, OPTIONAL sLine AS String)
DIM hForm AS Object
IF Instr(sPath, "/") = 0 THEN sPath = FindPath(sPath)
IF NOT Exist(sPath) THEN
Message.Warning("File not found!")
Project.Refresh
RETURN
ENDIF
'IF File.Ext(sPath) = "form" THEN
' FProperty.Show
' FToolBox.Show
'ENDIF
LoadFile(sPath)
hForm = Files[sPath]
IF NOT hForm THEN RETURN
TRY hForm.SetReadOnly(Project.Running)
hForm.Show
IF Object.Type(hForm) = "FEditor" THEN
hForm.Editor.SetFocus
IF sLine THEN hForm.Goto(CInt(sLine))
ENDIF
IF Object.Type(hForm) = "FForm" THEN
'hForm.control[sLine].SetFocus
IF sLine THEN hForm.Goto(sLine)
ENDIF
END
Yizhou He
Research Technician (Xiong Lab)
Lineberger Comprehensive Cancer Center
University of North Carolina at Chapel Hill
Chapel Hill, NC 27599-7295
Tel: (919)-962-2143
More information about the Devel
mailing list