[Gambas-user] Fwd: while working on PrettyPrinter, changes for the IDE Editor
Charlie Reinl
Karl.Reinl at ...9...
Sun Aug 15 23:25:33 CEST 2004
---------- Forwarded Message ----------
Subject: while working on PrettyPrinter, changes for the IDE Editor
Date: Sunday 15 August 2004 20:47
From: Charlie Reinl <Karl.Reinl at ...9...>
To: "gambas-user" <gambas-user at lists.sourceforge.net>
Salut,
for understanding the GambasEditor for using it for PrettyPrinter, I play
around with the IDE Editor and made the following changes in
PUBLIC SUB edtEditor_Cursor()
PUBLIC SUB edtEditor_Cursor()
IF edtEditor.Line <> $iLastLine THEN
' changings charlie
IF Left(Trim(edtEditor.Lines[$iLastLine]),1) <> "'" AND
Trim(edtEditor.Lines[$iLastLine]) <> ""THEN
edtEditor.Lines[$iLastLine] =
LineAnalyze(edtEditor.Lines[$iLastLine])
ENDIF
' end changings charlie
$iLastLine = edtEditor.Line
HideCompletion
HideSignature
IF IsModified() THEN Scan = NULL
ELSE IF $bCheckSignature OR frmSignature.Visible THEN
$bCheckSignature = FALSE
CheckSignature
ENDIF
DrawTitle
' TRY PRINT Editor.Analyze(Editor.Lines[Editor.Line]).Join(",")
END
For what LineAnalyze is for:
Till now it strippes useless Blanks and if you typed a i=i+1 you'v got no
error more , because LineAnalyze change it to i = i + 1
It dose only work on line and windows changes, It dosn't work if you press a
Button (Toolbar) without changing the line.
To you to play now.
Amicalement
Charlie
These procs are needed to make changes work ( not GetColorsName if you don't
uncomment the PRINT line in LineAnalyze)
PUBLIC SUB edtEditor_LostFocus()
IF Left(Trim(edtEditor.Lines[$iLastLine]),1) <> "'" AND
Trim(edtEditor.Lines[$iLastLine]) <> ""THEN
edtEditor.Lines[$iLastLine] =
LineAnalyze(edtEditor.Lines[$iLastLine]) ENDIF
END
'----------------------------------------------------------------------------
----------------------------------------------- PRIVATE FUNCTION
LineAnalyze(sLine AS String) AS String
DIM nI AS Integer
DIM sOut AS String
DIM sPart AS String[]
DIM iPart AS Integer[]
DIM aSPart AS Object
DIM sLeftBlanks AS String
IF IsProc(Trim(sLine)) THEN RETURN sLine
IF Upper(Trim(sLine)) = "END" THEN RETURN sLine
' looking for leading Blanks
FOR nI = 1 TO Len(sLine)
IF Mid(sLine,ni,1) = " " THEN
sLeftBlanks = sLeftBlanks & " "
ELSE
BREAK
ENDIF
NEXT
edtEditor.Analyze(sLine)
sPart=GambasEditor.Symbols
iPart=GambasEditor.Types
FOR nI = 0 TO sPart.Count - 1
SELECT CASE iPart[nI]
CASE 5 ' Symbol
' here you can look up if this Symbol is written as declaret
sOut = sOut & " " & sPart[nI] ' Sorry this line is missing in first
mail
CASE 6 ' Number
IF nI > 0 THEN
SELECT CASE iPart[nI - 1]
CASE 5 ' Symbol
sOut = sOut & " " & Left(sPart[nI],1) & " " &
Mid(sPart[nI],2)
CASE ELSE
sOut = sOut & " " & sPart[nI]
END SELECT
ELSE
sOut = sOut & " " & sPart[nI]
ENDIF
CASE ELSE
sOut = sOut & " " & sPart[nI]
END SELECT
'PRINT sPart[nI] , iPart[nI] , GetColorsName(iPart[nI])
NEXT
sOut = sLeftBlanks & Trim(sOut)
RETURN sOut
END
'----------------------------------------------------------------------------
----------------------------------------------- FUNCTION GetColorsName(iType
AS Integer) AS String
' this is only to know the Values
DIM sOut AS String
SELECT CASE iType
CASE edtEditor.Colors.Background
sOut = "Background"
CASE edtEditor.Colors.Breakpoint
sOut = "Breakpoint"
CASE edtEditor.Colors.Comment
sOut = "Comment"
CASE edtEditor.Colors.Current
sOut = "Current"
CASE edtEditor.Colors.DataType
sOut = "DataType"
CASE edtEditor.Colors.Function
sOut = "Function"
CASE edtEditor.Colors.Keyword
sOut = "Keyword"
CASE edtEditor.Colors.Normal
sOut = "Normal"
CASE edtEditor.Colors.Number
sOut = "Number"
CASE edtEditor.Colors.Operator
sOut = "Operator"
CASE edtEditor.Colors.String
sOut = "String"
CASE edtEditor.Colors.Symbol
sOut = "Symbol"
CASE ELSE
sOut = "??"
END SELECT
RETURN sOut
END
-------------------------------------------------------
More information about the User
mailing list