Sublime 3 - Python3 - linux :)

Linux specific forum
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Sublime 3 - Python3 - linux :)

Post by vwidmer »

I am not the original author of this I only tried to fix the original from:

Code: Select all

https://www.purebasic.fr/english/viewtopic.php?f=7&t=49273&hilit=sublime&sid=b9075562ea241772e64f71c2249197b2
I made some slight changes to make it work on Sublime 3, and with Python3 and on Linux :)

Doubt it will work on Windows or OSX.

Anyways here it is:
https://sync.usingssl.com/index.php/s/kcNgbJEf4mYYkdd

You will probably need to edit the file "PureBasic.sublime-build" and correct the paths to your installation.

I dont use the "pbcompiler" much so I dont know all the switches.

Can view what I left / added / removed the "Sublime -> Tools -> PureBasic - Compiler Options" menu.

If you change something or want something added let me know and I can try.

Also I am very new to python so I tried what I could to fix the "PureBasic.py" and it seems to be working but if some one has more skill/knowledge then me then please check it.

Have fun.
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

Re: Sublime 3 - Python3 - linux :)

Post by Justin »

That's great, thanks.
I did a quick test and found a little issue, if you have a folder with the same name of the file you try to compile in the same location it fails.
Is it possible to have a function listing to jump to a function?
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Re: Sublime 3 - Python3 - linux :)

Post by vwidmer »

Justin wrote:That's great, thanks.
I did a quick test and found a little issue, if you have a folder with the same name of the file you try to compile in the same location it fails.
Is it possible to have a function listing to jump to a function?
do you mean can have the file and folder in same directory? or do you mean when the file to compile is in a folder that has the same name?

Also can you please give me an example of what u mean by jump to function? I dont understand fully.

Thanks
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

Re: Sublime 3 - Python3 - linux :)

Post by Justin »

I can't test the folder thing now, i will check later.

The function listing is like the procedure browser in the PB IDE, a listbox that displays the available procedures on the current file and when you click on one the editor jumps to the procedure declaration.
I think ST has something like a go to symbol option that displays the available methods/structures o whatever and you can jump to the declaration.
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Re: Sublime 3 - Python3 - linux :)

Post by vwidmer »

WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

Re: Sublime 3 - Python3 - linux :)

Post by Justin »

Yes something like that, it's pretty good now, although it does not update live, you have to close it and open again to reflect the changes, is there a shortcut to refresh?
Also it would be nice if scanned for structures and interfaces and maybe the ';- ' marker like in the PB IDE.

Can the structures and interface autocomplete be implemented? Like when you type a structure and pops up the structure fields.

Forget the folder issue it was a problem of mine.

Another thing i have noticed is that the debug statements only appear in the console after the program exits, not during execution, this can be a problem. Maybe using to separate steps build / run would solve it?
For example:

Code: Select all

debug "open"

OpenWindow(0, 0, 0, 600, 300, "foo", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

debug "opened"
   
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

debug "exit"
Debugs only show when you exit.
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Re: Sublime 3 - Python3 - linux :)

Post by vwidmer »

Try updating the "PureBasic.sublime-build"

to look like this particularly line 2 just make sure you fix your PB location

Code: Select all

{
    "cmd": ["stdbuf","-oL","/opt/purebasic/compilers/pbcompiler", "$file"],
    "path": "/opt/purebasic/compilers:$PATH",
    "file_regex": "\\s'?(.:.+\\.pb)'?",
    "line_regex": "[ ]*Line ([0-9]*)",
    "target": "buildpb",
    "selector": "source.purebasic=",
    "env":
  {
    "PUREBASIC_HOME": "/opt/purebasic"
  }
}
That should show the debug stuff.
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

Re: Sublime 3 - Python3 - linux :)

Post by Justin »

Hi vwidmer, it's strange the first time i tried it it worked, then it does not work any more, when building, the status bar shows Building for a few seconds and nothing happens. removing "stdbuf","-oL", builds as before.
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Re: Sublime 3 - Python3 - linux :)

Post by vwidmer »

maybe try just running something like

Code: Select all

stdbuf -oL date
in a terminal and see if there is some issue.

or maybe try replacing stdbuf with the full path? Mine is "/usr/bin/stdbuf"

can find it via

Code: Select all

which stdbuf
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Justin
Addict
Addict
Posts: 829
Joined: Sat Apr 26, 2003 2:49 pm

Re: Sublime 3 - Python3 - linux :)

Post by Justin »

The date works well.
The editor same as before, the first time build works showing the debugs well, and then it does not work anymore.

I have noticed that the language plugin format is very similar to the visual studio code one, maybe it would be easy for you to port it? It is free and really good.
Post Reply