Page 4 of 5

Posted: Sat Feb 26, 2005 11:44 am
by gnozal
PB wrote:A suggestion for GPI: Perhaps save the Version info for a source in a different
file than the source? I opened one of my apps in the PureBasic editor and
after saving it, all my Version info was gone. :(
Of better make it optional, because I like it the way it is.

Posted: Sat Feb 26, 2005 12:05 pm
by PB
> make it optional

Yeah, that'd be fine. I just think it's bad to open a source in one editor and
have it destroy the data that was saved by another editor. Makes it too risky.

Posted: Sun Feb 27, 2005 12:39 am
by Le Soldat Inconnu
Hello

An idea :

I don't use jaPBe indentation because we can't add new terms.

for example, i add an indentation after
StartDrawing(...)
scrollareagadget(...)
containergadget(...)
panelgadget(...)
etc...

It's very useful if we can add news terms for indentation rules

Thanks

Posted: Sun Feb 27, 2005 10:45 am
by freedimension
Le Soldat Inconnu wrote: It's very useful if we can add news terms for indentation rules
It's a little bit more typing, but try

Code: Select all

CompilerIf a=b ;>
  doSomethingHere()
CompilerElse ;=
  doSomethingElse()
CompilerEndif ;<
The reason why it's not implemented generally for StartDrawing, CompilerIf etc. is that the matching functions don't necessarily need to lay on the same indentation level.

Posted: Sun Feb 27, 2005 12:52 pm
by Le Soldat Inconnu
Hello

I do the modification :D

i used the same way as my program PBSyntax (this program make indentation)

So you can add term for indentation or remove term.

Change :

I create a preference file file where are save indentation word
Name : "Indentation.txt"
You must create this file in the same folder of jabpe
This file contains :
; Word In Out

select 2 0
case 1 1
default 1 1
endselect 0 2

for 1 0
foreach 1 0
next 0 1

if 1 0
else 1 1
elseif 1 1
endif 0 1

opensubmenu 1 0
closesubmenu 0 1

procedure 1 0
proceduredll 1 0
procedurecdll 1 0
endprocedure 0 1

repeat 1 0
until 0 1
forever 0 1

structure 1 0
endstructure 0 1

while 1 0
wend 0 1

datasection 1 0
enddatasection 0 1

enumeration 1 0
endenumeration 0 1

interface 1 0
endinterface 0 1

startdrawing 1 0
stopdrawing 0 1

containergadget 1 0
panelgadget 1 0
scrollareagadget 1 0
opengadgetlist 1 0
closegadgetlist 0 1

start3d 1 0
stop3d 0 1

compilerif 1 0
compilerelse 1 1
compilerelseif 1 1
compilerendif 0 1
In the file jaPBe.pb, I add the procedure which load indentation word

Code: Select all

Procedure LoadList_Indentation() ; Load indentation word : LSI
  Protected Txt.s
  If OpenFile(0, "Indentation.txt")
    Repeat
      Txt.s = Trim(ReadString())
      If Txt And Left(Txt, 1) <> ";"
        AddElement(IndentationWord())
        IndentationWord()\_Word = Trim(StringField(Txt, 1, Chr(9)))
        IndentationWord()\_Len = Len(IndentationWord()\_Word)
        IndentationWord()\_In = Val(Trim(StringField(Txt, 2, Chr(9))))
        IndentationWord()\_Out = Val(Trim(StringField(Txt, 3, Chr(9))))
      EndIf
    Until Eof(0)
    CloseFile(0)
  EndIf
EndProcedure
You can placed this procedure after "Procedure LoadList_Skin()"

and add this line "LoadList_Indentation() ; LSI" here

Code: Select all

;-Start of editor
LoadList_IncludePack()
LoadList_Definitions()
LoadList_Styles()
LoadList_Language()
LoadList_Skin()
LoadList_Indentation() ; LSI
preference_load()
CreateCustomButtons()

In the "Common.pbi"

You must change the structure FIC_Information by this

Code: Select all

Structure FIC_Information; Indentation : LSI
  _In.l ; LSI
  _Out.l ; LSI
  ; _if.l
  ; _else.l
  ; _endif.l
  ; _elseif.l
  ; _Select.l
  ; _case.l
  ; _endselect.l
  ; _wend.l
  ; _while.l
  ; _until.l
  ; _repeat.l
  ; _procedure.l
  ; _endprocedure.l
  ; _for.l
  ; _next.l
  ; _structure.l
  ; _endstructure.l
  ; _enumeration.l
  ; _endenumeration.l
  ; _interface.l
  ; _endinterface.l
  ; _structureunion.l
  ; _endstructureunion.l
  ; _manualIn.l
  ; _manualOut.l
  ; _manualSame.l
  EmptyLine.l
EndStructure
You must add a new structure

Code: Select all

Structure IndentationWord_Information ; Definition of indentation words : LSI
  _Len.l
  _Word.s
  _In.l
  _Out.l
EndStructure
You must create a new list

Code: Select all

NewList IndentationWord.IndentationWord_Information() ; List contained word use in indentation : LSI

In the file Editor-Core.pbi

You must replace the procedure "FindIndentationChange" by this

Code: Select all

Procedure FindIndentationChange(line,*Result.FIC_Information)
  *Result\EmptyLine=0
  *Result\_In=0 ; LSI
  *Result\_Out=0 ; LSI
  ; *Result\_manualIn=0
  ; *Result\_manualOut=0
  ; *Result\_manualSame=0
  ; *Result\_if=0
  ; *Result\_else=0
  ; *Result\_endif=0
  ; *Result\_elseif=0
  ; *Result\_Select=0
  ; *Result\_case=0
  ; *Result\_endselect=0
  ; *Result\_wend=0
  ; *Result\_while=0
  ; *Result\_until=0
  ; *Result\_repeat=0
  ; *Result\_procedure=0
  ; *Result\_endprocedure=0
  ; *Result\_for=0
  ; *Result\_next=0
  ; *Result\_structure=0
  ; *Result\_endstructure=0
  ; *Result\_structureunion=0
  ; *Result\_endstructureunion=0
  ; *Result\_enumeration=0
  ; *Result\_endenumeration=0
  ; *Result\_interface=0
  ; *Result\_endinterface=0
  length=SCI_LineLength(line)
  memhandle=AllocateMemory(length+10)
  adr=memhandle+5
  If adr
    If SCI_GetLine(line,adr)
      *buf.BYTE=adr
      While *buf\b=13 Or *buf\b=10 Or *buf\b=' ' Or *buf\b=8
        *buf+1
      Wend
      If *buf\b=';' Or *buf\b=0
        *Result\EmptyLine=#True
      Else
        *buf.BYTE=adr
        Repeat
          While AllowedChars(*buf\b&$FF)=#False And *buf\b<>0
            Select *buf\b&$FF
              Case '#'
                *buf+1
                While AllowedChars(*buf\b&$FF)
                  *buf+1
                Wend
              Case 39
                *buf+1
                While *buf\b&$FF<>39 And *buf\b<>0
                  *buf+1
                Wend
                If *buf\b=39
                  *buf+1
                EndIf
              Case '"'
                *buf+1
                While *buf\b&$FF<>'"' And *buf\b<>0
                  *buf+1
                Wend
                If *buf\b='"'
                  *buf+1
                EndIf
              Case ';'
                Select PeekB(*buf+1)&$FF
                  ; Case '>':*Result\_manualIn+1
                  ; Case '=':*Result\_manualSame+1
                  ; Case '<':*Result\_manualOut+1
                  Case '>' : *Result\_In + 1 ; manual indentation : LSI
                  Case '=' : *Result\_In + 1 : *Result\_Out + 1
                  Case '<' : *Result\_Out + 1
                EndSelect
                *buf\b=0
              Default
                *buf+1
            EndSelect
          Wend
          *WordStart.BYTE=*buf
          While AllowedChars(*buf\b&$FF)
            *buf+1
          Wend
          
          LenWord.l = *buf-*WordStart  ; Search indentation word : LSI
          ForEach IndentationWord()
            If LenWord = IndentationWord()\_Len
              If CompareMemoryString(*WordStart, @IndentationWord()\_Word, 1, LenWord)=0
                *Result\_In + IndentationWord()\_In
                *Result\_Out + IndentationWord()\_Out
              EndIf
            EndIf
          Next
          
          ; Select *buf-*WordStart
            ; Case 2
              ; If CompareMemoryString(*WordStart,@"If",1,2)=0
                ; *Result\_if+1
              ; EndIf
            ; Case 3
              ; If CompareMemoryString(*WordStart,@"For",1,3)=0
                ; *Result\_for+1
              ; EndIf          
            ; Case 4
              ; If CompareMemoryString(*WordStart,@"Else",1,4)=0
                ; If *Result\_if=0
                  ; *Result\_else+1
                ; EndIf
              ; ElseIf CompareMemoryString(*WordStart,@"Case",1,4)=0
                ; If *Result\_Select=0
                  ; *Result\_case=1
                ; EndIf
              ; ElseIf CompareMemoryString(*WordStart,@"Wend",1,4)=0
                ; If *Result\_while
                  ; *Result\_while-1
                ; Else
                  ; *Result\_wend+1
                ; EndIf
              ; ElseIf CompareMemoryString(*WordStart,@"Next",1,4)=0
                ; If *Result\_for
                  ; *Result\_for-1
                ; Else
                  ; *Result\_next+1
                ; EndIf
              ; EndIf
            ; Case 5
              ; If CompareMemoryString(*WordStart,@"EndIf",1,5)=0
                ; If *Result\_if
                  ; *Result\_if-1
                ; Else
                  ; *Result\_endif+1
                ; EndIf
              ; ElseIf CompareMemoryString(*WordStart,@"While",1,5)=0
                ; *Result\_while+1
              ; ElseIf CompareMemoryString(*WordStart,@"Until",1,5)=0
                ; If *Result\_repeat
                  ; *Result\_repeat-1
                ; Else
                  ; *Result\_until+1
                ; EndIf
              ; EndIf
            ; Case 6
              ; If CompareMemoryString(*WordStart,@"Repeat",1,6)=0
                ; *Result\_repeat+1
              ; ElseIf CompareMemoryString(*WordStart,@"Select",1,6)=0
                ; *Result\_Select+1
              ; ElseIf CompareMemoryString(*WordStart,@"ElseIf",1,6)=0
                ; If *Result\_if=0
                  ; *Result\_elseif+1
                ; EndIf
              ; EndIf
            ; Case 7
              ; If CompareMemoryString(*WordStart,@"Default",1,7)=0
                ; If *Result\_Select=0
                  ; *Result\_case+1
                ; EndIf
              ; ElseIf CompareMemoryString(*WordStart,@"ForEver",1,7)=0
                ; If *Result\_repeat
                  ; *Result\_repeat-1
                ; Else
                  ; *Result\_until+1
                ; EndIf
              ; ElseIf CompareMemoryString(*WordStart,@"ForEach",1,7)=0
                ; *Result\_for+1
              ; EndIf 
            ; Case 9
              ; If CompareMemoryString(*WordStart,@"EndSelect",1,9)=0
                ; If *Result\_Select
                  ; *Result\_Select-1
                ; Else
                  ; *Result\_endselect+1
                ; EndIf
              ; ElseIf CompareMemoryString(*WordStart,@"Procedure",1,9)=0
                ; *Result\_procedure+1
              ; ElseIf CompareMemoryString(*WordStart,@"Structure",1,9)=0
                ; *Result\_structure+1
              ; ElseIf CompareMemoryString(*WordStart,@"Interface",1,9)=0
                ; *Result\_interface+1
              ; EndIf
            ; Case 11
              ; If CompareMemoryString(*WordStart,@"Enumeration",1,11)=0
                ; *Result\_enumeration+1
              ; EndIf
            ; Case 12
              ; If CompareMemoryString(*WordStart,@"EndProcedure",1,12)=0
                ; If *Result\_procedure
                  ; *Result\_procedure-1
                ; Else
                  ; *Result\_endprocedure+1
                ; EndIf
              ; ElseIf CompareMemoryString(*WordStart,@"ProcedureDLL",1,12)=0
                ; *Result\_procedure+1
              ; ElseIf CompareMemoryString(*WordStart,@"EndStructure",1,12)=0
                ; If *Result\_structure
                  ; *Result\_structure-1
                ; Else
                  ; *Result\_endstructure+1
                ; EndIf
              ; ElseIf CompareMemoryString(*WordStart,@"EndInterface",1,12)=0
                ; If *Result\_interface
                  ; *Result\_interface-1
                ; Else
                  ; *Result\_endinterface+1
                ; EndIf
              ; EndIf
            ; Case 13
              ; If CompareMemoryString(*WordStart,@"ProcedureCDLL",1,12)=0
                ; *Result\_procedure+1
              ; EndIf
            ; Case 14
              ; If CompareMemoryString(*WordStart,@"StructureUnion",1,14)=0
                ; *Result\_structureunion+1
              ; ElseIf CompareMemoryString(*WordStart,@"EndEnumeration",1,14)=0
                ; If *Result\_enumeration
                  ; *Result\_enumeration-1
                ; Else
                  ; *Result\_endenumeration+1
                ; EndIf
              ; EndIf
            ; Case 17
              ; If CompareMemoryString(*WordStart,@"EndStructureUnion",1,17)=0
                ; If *Result\_structureunion
                  ; *Result\_structureunion-1
                ; Else
                  ; *Result\_endstructureunion+1
                ; EndIf
              ; EndIf
          ; EndSelect
        Until *buf\b=0     
      EndIf
    EndIf      
    FreeMemory(memhandle)
  EndIf      
EndProcedure
And replace the procedure "ChangeIndentation" by this

Code: Select all

Procedure ChangeIndentation(line,ChangePos)
  If Sources()\SourceType<>#SourceType_PureBasic
    ProcedureReturn #False
  EndIf
  If line>=SCI_GetLineCount()
    ProcedureReturn 0
  EndIf
  If line>-1
    change=0:offset=0:dochange=0
    
    If AutoInsert
      FindIndentationChange(line,LineFlag.FIC_Information)
      offset+(Tab*LineFlag\_In) ; LSI
      ; offset+(Tab*LineFlag\_manualIn)
      ; offset+(Tab*LineFlag\_manualSame)
      ; offset+(Tab*LineFlag\_if)
      ; offset+(Tab*LineFlag\_elseif)
      ; offset+(Tab*LineFlag\_else)
      ; offset+(Tab*LineFlag\_Select)
      ; offset+(Tab*LineFlag\_case)
      ; offset+(Tab*LineFlag\_while)
      ; offset+(Tab*LineFlag\_repeat)
      ; offset+(Tab*LineFlag\_procedure)
      ; offset+(Tab*LineFlag\_structure)
      ; offset+(Tab*LineFlag\_structureunion)
      ; offset+(Tab*LineFlag\_interface)
      ; offset+(Tab*LineFlag\_enumeration)
      ; offset+(Tab*LineFlag\_for)
      
      If line>0
        xLine=line
        BeforeFlag.FIC_Information
        BeforeFlag\EmptyLine=#True
        Repeat
          If BeforeFlag\EmptyLine=#True
            xLine-1
          EndIf
          FindIndentationChange(xLine,BeforeFlag.FIC_Information)
        Until xLine<=0 Or BeforeFlag\EmptyLine=0
        change+(Tab*BeforeFlag\_In) : dochange+BeforeFlag\_In ; LSI
        ; change+(Tab*BeforeFlag\_manualIn) :dochange+BeforeFlag\_manualIn
        ; change+(Tab*BeforeFlag\_manualSame):dochange+BeforeFlag\_manualSame
        ; change+(Tab*BeforeFlag\_if)       :dochange+BeforeFlag\_if
        ; change+(Tab*BeforeFlag\_elseif)   :dochange+BeforeFlag\_elseif
        ; change+(Tab*BeforeFlag\_else)     :dochange+BeforeFlag\_else
        ; change+(Tab*BeforeFlag\_Select)   :dochange+BeforeFlag\_Select
        ; change+(Tab*BeforeFlag\_case)     :dochange+BeforeFlag\_case
        ; change+(Tab*BeforeFlag\_while)    :dochange+BeforeFlag\_while
        ; change+(Tab*BeforeFlag\_repeat)   :dochange+BeforeFlag\_repeat
        ; change+(Tab*BeforeFlag\_procedure):dochange+BeforeFlag\_procedure
        ; change+(Tab*BeforeFlag\_structure):dochange+BeforeFlag\_structure
        ; change+(Tab*BeforeFlag\_structureunion):dochange+BeforeFlag\_structureunion
        ; change+(Tab*BeforeFlag\_interface):dochange+BeforeFlag\_interface
        ; change+(Tab*BeforeFlag\_enumeration):dochange+BeforeFlag\_enumeration
        ; change+(Tab*BeforeFlag\_for)     :dochange+BeforeFlag\_for

      Else
        BeforeFlag.FIC_Information
      EndIf
      
      change-(Tab*LineFlag\_Out) : dochange + LineFlag\_Out ; LSI
       ; While LineFlag\_manualOut
        ; dochange=#True
        ; LineFlag\_manualOut-1
        ; change-Tab
      ; Wend
      ; While LineFlag\_manualSame
        ; LineFlag\_manualSame-1
        ; change-Tab:dochange=#True
        ; ;offset+Tab
      ; Wend 
      ; While LineFlag\_endif
        ; dochange=#True
        ; LineFlag\_endif-1
        ; change-Tab
      ; Wend
      ; While LineFlag\_elseif
        ; LineFlag\_elseif-1
        ; change-Tab:dochange=#True
      ; Wend
      ; While LineFlag\_else
        ; LineFlag\_else-1
        ; change-Tab:dochange=#True
        ; ;offset+Tab
      ; Wend 
      ; While LineFlag\_case
        ; LineFlag\_case-1
        ; If BeforeFlag\_case Or BeforeFlag\_Select=0
          ; change-Tab:dochange=#True
        ; EndIf
      ; Wend
      ; While LineFlag\_endselect
        ; LineFlag\_endselect-1
        ; If BeforeFlag\_Select=0
          ; change-(Tab+Tab):dochange=#True
        ; Else
          ; BeforeFlag\_Select-1
          ; change-Tab:dochange=#True
        ; EndIf
      ; Wend
      ; change-(Tab*LineFlag\_wend):         dochange+LineFlag\_wend
      ; change-(Tab*LineFlag\_until):        dochange+LineFlag\_until
      ; change-(Tab*LineFlag\_endprocedure): dochange+LineFlag\_endprocedure
      ; change-(Tab*LineFlag\_endstructure): dochange+LineFlag\_endstructure
      ; change-(Tab*LineFlag\_endstructureunion): dochange+LineFlag\_endstructureunion
      ; change-(Tab*LineFlag\_endenumeration): dochange+LineFlag\_endenumeration
      ; change-(Tab*LineFlag\_endinterface): dochange+LineFlag\_endinterface
      ; change-(Tab*LineFlag\_next):         dochange+LineFlag\_next
      
      ok=#True
      If xLine>=0
        len=SCI_GetLineIndentation(xLine)
        If dochange Or SCI_GetLineIndentation(line)<>len
          len+change
          ;Debug " Offset:"+Str(SCI_GetLineIndentation(xLine))+" "+Str(change)
          len=(len/Tab)*Tab
          If LineFlag\EmptyLine=0
            SCI_SetLineIndentation(line,len)
          EndIf
          ok=#False
        EndIf
      EndIf
      If ok
        len=SCI_GetLineIndentation(line)
        len=(len/Tab)*Tab
      EndIf
      
      len+offset
      
      If len>0
        If ChangePos
          SCI_SetLineIndentation(line+1,len)
        EndIf
        If ChangePos=2
          Pos=SCI_PositionFromLine(line+1)
          SCI_GotoPos(Pos+len)
        EndIf
        SpaceAdded=#True
      Else
        SpaceAdded=#False
      EndIf
    EndIf
  EndIf
EndProcedure

And compile :D

Now, you can edit the file Indentation.txt to add or remove indentation word :wink:

You can download this to test my modification : (autocompletion don't work with this change)
http://perso.wanadoo.fr/lesoldatinconnu ... /jaPBe.zip (250ko)



What do you thinks about this ?

Posted: Sun Feb 27, 2005 3:28 pm
by Flype
good, it is what was missing to jaPBe.

Posted: Sun Feb 27, 2005 3:40 pm
by Le Soldat Inconnu
My modification works now with autocompletion :)
Autocompletion word is in the file "indentation.txt".

For example, if i write StartDrawing(...) , autocompletion write StopDrawing().
if you edit the "indentation.txt" file, you can add or remove word use by autocompletion.

And I add modified files in the zip (see my previous message to download it)
To find modification, search "LSI" in the file :wink:

Posted: Mon Feb 28, 2005 12:06 pm
by gnozal
good, it is what was missing to jaPBe.
I agree.
@GPI : it would be nice to see this feature in the next 'official' jaPBe releases.

Posted: Mon Feb 28, 2005 8:44 pm
by Le Soldat Inconnu
I had a panel in preferences window to edit indentation keyword and auto completion keyword. and I post it :D

Posted: Mon Feb 28, 2005 9:17 pm
by Flype
@GPI

those modifications sounds good...
hope you are agree to update your so usefull jaPBe.

Posted: Wed Mar 02, 2005 12:49 am
by Le Soldat Inconnu
I finish :D

http://perso.wanadoo.fr/lesoldatinconnu ... /jaPBe.zip (340ko)
Source files are included in the zip, search "LSI" to find my modification.

See jaPBe preference to edit indentation and autocompletation keywords ;)

What do you think about that ?

GPI, tell me your opinion about my idea and about my modification, thanks :)

Posted: Wed Mar 02, 2005 9:27 am
by dige
Looks nice. I like it. Hope GPI will like it too ;-)

Posted: Wed Mar 02, 2005 12:02 pm
by Le Soldat Inconnu
I correct an error with DataSection and EndDataSection case
and i correct an other error when you change the language

Edit : An other error, i write twice ProcedureDLL in indentation keywords.
So you can delete a ProcedureDLL keywords in preferences to correct this problem if you are already download my modification ;)

Posted: Sat Mar 12, 2005 7:28 am
by Shannara
Any way to make jaPBe to automatically include the declare files when running/compiling an app?

Posted: Sat Mar 12, 2005 12:48 pm
by GPI
Shannara wrote:Any way to make jaPBe to automatically include the declare files when running/compiling an app?
At them moment simple with
XIncludefile "all.declare"