NewTab - IDE-Tool

Share your advanced PureBasic knowledge/code with the community.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

NewTab - IDE-Tool

Post by ts-soft »

This tool use the new trigger: "New Sourcecode created"
This code is not optimized and you have to change the first 3 constants!

Code: Select all

; Configure as
;
; Commandline: "%TEMPFILE"
; Trigger: "New Sourcecode created"
; [x] Wait until tool quits
; [x] Reload Source after tool has quit
;      (x) into current source
; [x] Hide tool from the Main menu
;

EnableExplicit

#APP_NAME_DEFAULT$ = "Example"
#AUTHOR_DEFAULT$ = "Thomas <ts-soft> Schulz"
#VERSION_DEFAULT$ = "0.0"

Procedure.s GetPBCompilerVersion()
  Protected Compiler, result.s
  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_Windows
      Compiler = RunProgram(GetEnvironmentVariable("PB_TOOL_Compiler"), "/STANDBY", "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Write | #PB_Program_Hide)
    CompilerDefault
      Compiler = RunProgram(GetEnvironmentVariable("PB_TOOL_Compiler"), "--standby", "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Write | #PB_Program_Hide)
  CompilerEndSelect
  If Compiler
    result = StringField(ReadProgramString(Compiler), 3, #TAB$)
    WriteProgramStringN(Compiler, "END")
    CloseProgram(Compiler)
  EndIf
  ProcedureReturn result
EndProcedure

Procedure.s ReadPBPrefs(group.s, key.s)
  Protected result.s, prefs.s = GetEnvironmentVariable("PB_TOOL_Preferences")
  
  If OpenPreferences(prefs)
    PreferenceGroup(group)
    result = ReadPreferenceString(key, "")
    ClosePreferences()
  EndIf
  ProcedureReturn result
EndProcedure

Define.s File = ProgramParameter()
Define FF, Format
FF = CreateFile(#PB_Any, File)
If FF
  Select ReadPBPrefs("CompilerDefaults", "TextEncoding")
    Case "1"
      Format = #PB_UTF8
    Default
      Format = #PB_Ascii
  EndSelect
  WriteStringFormat(FF, Format)
  WriteStringN(FF, "; ==============================================================", Format)
  WriteStringN(FF, "; COMPILER OPTIONS:", Format)
  Select ReadPBPrefs("CompilerDefaults", "InlineASM")
    Case "0"
      WriteStringN(FF, ";  [ ] Enable inline ASM support", Format)
    Default
      WriteStringN(FF, ";  [x] Enable inline ASM support", Format)
  EndSelect
  Select ReadPBPrefs("CompilerDefaults", "Unicode")
    Case "0"
      WriteStringN(FF, ";  [ ] Create unicode executable", Format)
    Default
      WriteStringN(FF, ";  [x] Create unicode executable", Format)
  EndSelect
  Select ReadPBPrefs("CompilerDefaults", "Thread")
    Case "0"
      WriteStringN(FF, ";  [ ] Create threadsafe executable", Format)
    Default
      WriteStringN(FF, ";  [x] Create threadsafe executable", Format)
  EndSelect
  Select ReadPBPrefs("CompilerDefaults", "OnError")
    Case "0"
      WriteStringN(FF, ";  [ ] Enable OnError lines support", Format)
    Default
      WriteStringN(FF, ";  [x] Enable OnError lines support", Format)
  EndSelect
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    Select ReadPBPrefs("CompilerDefaults", "XPSkin")
      Case "0"
        WriteStringN(FF, ";  [ ] Enable XP skin support", Format)
      Default
        WriteStringN(FF, ";  [x] Enable XP skin support", Format)
    EndSelect
    Select ReadPBPrefs("CompilerDefaults", "VistaAdmin")
      Case "0"
        WriteStringN(FF, ";  [ ] Request Administrator mode for Windows Vista", Format)
      Default
        WriteStringN(FF, ";  [x] Request Administrator mode for Windows Vista", Format)
    EndSelect
    Select ReadPBPrefs("CompilerDefaults", "VistaUser")
      Case "0"
        WriteStringN(FF, ";  [ ] Request User mode for Windows Vista (no virtualization)", Format)
      Default
        WriteStringN(FF, ";  [x] Request User mode for Windows Vista (no virtualization)", Format)
    EndSelect
  CompilerEndIf
  WriteStringN(FF, "; Library Subsystem:  " + ReadPBPrefs("CompilerDefaults", "SubSystem"), Format)
  Select ReadPBPrefs("CompilerDefaults", "TextEncoding")
    Case "1"
      WriteStringN(FF, "; File Format:        UTF-8", Format)
    Default
      WriteStringN(FF, "; File Format:        ASCII", Format)
  EndSelect
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    Select ReadPBPrefs("CompilerDefaults", "ExeFormat")
      Case "1"
        WriteStringN(FF, "; Executable Format:  Console", Format)
      Case "2"
        WriteStringN(FF, "; Executable Format:  Shared DLL", Format)
      Default
        WriteStringN(FF, "; Executable Format:  Windows", Format)
    EndSelect
  CompilerElse
    Select ReadPBPrefs("CompilerDefaults", "ExeFormat")
      Case "1"
        WriteStringN(FF, "; Executable Format:  Console", Format)
      Case "2"
        WriteStringN(FF, "; Executable Format:  Shared .so", Format)
      Default
        WriteStringN(FF, "; Executable Format:  Linux", Format)
    EndSelect
  CompilerEndIf
  WriteStringN(FF, ";", Format)
  WriteStringN(FF, "; Created on:         " + FormatDate("%dd/%mm/%yyyy %hh:%ii", Date()), Format)
  WriteStringN(FF, "; App/Lib-Name:       " + #APP_NAME_DEFAULT$, Format)
  WriteStringN(FF, "; Author:             " + #AUTHOR_DEFAULT$, Format)
  WriteStringN(FF, "; Version:            " + #VERSION_DEFAULT$, Format)
  WriteStringN(FF, "; Compiler:           " + GetPBCompilerVersion(), Format)
  WriteStringN(FF, "; ==============================================================", Format)
  WriteStringN(FF, "", Format)
  WriteStringN(FF, "EnableExplicit", Format)
  WriteStringN(FF, "", Format)
  CloseFile(FF)
EndIf 
The result on my PC on Windows:

Code: Select all

; ==============================================================
; COMPILER OPTIONS:
;  [ ] Enable inline ASM support
;  [x] Create unicode executable
;  [ ] Create threadsafe executable
;  [ ] Enable OnError lines support
;  [x] Enable XP skin support
;  [ ] Request Administrator mode for Windows Vista
;  [x] Request User mode for Windows Vista (no virtualization)
; Library Subsystem:  
; File Format:        UTF-8
; Executable Format:  Windows
;
; Created on:         13/10/2012 21:21
; App/Lib-Name:       Example
; Author:             Thomas <ts-soft> Schulz
; Version:            0.0
; Compiler:           PureBasic 5.00 Beta 5 (Windows - x64)
; ==============================================================

EnableExplicit

Have fun
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
skywalk
Addict
Addict
Posts: 4212
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: NewTab - IDE-Tool

Post by skywalk »

Very Nice 8)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: NewTab - IDE-Tool

Post by ts-soft »

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: NewTab - IDE-Tool

Post by Fred »

Interesting idea !
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: NewTab - IDE-Tool

Post by Zebuddi123 »

Thanks for sharing :D just what is needed great :idea:

Iv`e added a window/gadgets for title and version for my own use. in case anyone wants to try it

Code: Select all

; Configure as
;
; Commandline: "%TEMPFILE"
; Trigger: "New Sourcecode created"
; [x] Wait until tool quits
; [x] Reload Source after tool has quit
;      (x) into current source
; [x] Hide tool from the Main menu
;

EnableExplicit

; #APP_NAME_DEFAULT$ = "Example"
#AUTHOR_DEFAULT$ = " Your Title Here "
; #VERSION_DEFAULT$ = "0.0"

Procedure.s GetPBCompilerVersion()
	Protected Compiler, result.s
	CompilerSelect #PB_Compiler_OS
		CompilerCase #PB_OS_Windows
			Compiler = RunProgram(GetEnvironmentVariable("PB_TOOL_Compiler"), "/STANDBY", "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Write | #PB_Program_Hide)
		CompilerDefault
			Compiler = RunProgram(GetEnvironmentVariable("PB_TOOL_Compiler"), "--standby", "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Write | #PB_Program_Hide)
	CompilerEndSelect
	If Compiler
		result = StringField(ReadProgramString(Compiler), 3, #TAB$)
		WriteProgramStringN(Compiler, "END")
		CloseProgram(Compiler)
	EndIf
	ProcedureReturn result
EndProcedure

Procedure.s ReadPBPrefs(group.s, key.s)
	Protected result.s, prefs.s = GetEnvironmentVariable("PB_TOOL_Preferences")
	
	If OpenPreferences(prefs)
		PreferenceGroup(group)
		result = ReadPreferenceString(key, "")
		ClosePreferences()
	EndIf
	ProcedureReturn result
EndProcedure


;{ /////////////////////////////////////////////////////////
;{ ------------------------------------------------------
Enumeration
	#Window_0
EndEnumeration

Enumeration
	#Window_0_Text0_Title
	#Window_0_Text1_Version
	#Window_0_String2_2
	#Window_0_String3_3
	#Window_0_Button6_Done
EndEnumeration
;}

Procedure OpenWindow_Window_0()
	If OpenWindow(#Window_0, 698, 202, 402, 73, "Pure Source File Setup", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)		 
		TextGadget(#Window_0_Text0_Title, 10, 10, 40, 15, "Title", #PB_Text_Center)
		TextGadget(#Window_0_Text1_Version, 15, 40, 40, 15, "Version", #PB_Text_Center)
		StringGadget(#Window_0_String2_2, 55, 10, 335, 20, "",#ES_CENTER)
		StringGadget(#Window_0_String3_3, 55, 36, 50, 20, "", #ES_CENTER)
		ButtonGadget(#Window_0_Button6_Done, 350, 40, 40, 20, "Done")
	EndIf
EndProcedure

;{------------------------------------------------------
Global gettitle$, getversion$
OpenWindow_Window_0()


Repeat
	Select WaitWindowEvent()
			; ///////////////////
		Case #PB_Event_Gadget
			Select EventGadget()
				Case #Window_0_Button6_Done
					 
					gettitle$=GetGadgetText(#Window_0_String2_2)
					If gettitle$="" :  gettitle$="Example" : EndIf
					
					getversion$=GetGadgetText(#Window_0_String3_3)
					If getversion$="": getversion$="0.0": EndIf
					
					CloseWindow(#Window_0)
					Break
			EndSelect
			; ////////////////////////
		Case #PB_Event_CloseWindow
			Select EventWindow()
				Case #Window_0
					CloseWindow(#Window_0)
					Break
			EndSelect
	EndSelect
ForEver
;}----------------------------------------------------------------------------
;}//////////////////////////////////////////////



;{




Define.s File = ProgramParameter()
Define FF, Format
FF = CreateFile(#PB_Any, File)
If FF
	Select ReadPBPrefs("CompilerDefaults", "TextEncoding")
		Case "1"
			Format = #PB_UTF8
		Default
			Format = #PB_Ascii
	EndSelect
	WriteStringFormat(FF, Format)
	WriteStringN(FF, "; ==============================================================", Format)
	WriteStringN(FF, "; COMPILER OPTIONS:", Format)
	Select ReadPBPrefs("CompilerDefaults", "InlineASM")
		Case "0"
			WriteStringN(FF, ";  [ ] Enable inline ASM support", Format)
		Default
			WriteStringN(FF, ";  [x] Enable inline ASM support", Format)
	EndSelect
	Select ReadPBPrefs("CompilerDefaults", "Unicode")
		Case "0"
			WriteStringN(FF, ";  [ ] Create unicode executable", Format)
		Default
			WriteStringN(FF, ";  [x] Create unicode executable", Format)
	EndSelect
	Select ReadPBPrefs("CompilerDefaults", "Thread")
		Case "0"
			WriteStringN(FF, ";  [ ] Create threadsafe executable", Format)
		Default
			WriteStringN(FF, ";  [x] Create threadsafe executable", Format)
	EndSelect
	Select ReadPBPrefs("CompilerDefaults", "OnError")
		Case "0"
			WriteStringN(FF, ";  [ ] Enable OnError lines support", Format)
		Default
			WriteStringN(FF, ";  [x] Enable OnError lines support", Format)
	EndSelect
	CompilerIf #PB_Compiler_OS = #PB_OS_Windows
		Select ReadPBPrefs("CompilerDefaults", "XPSkin")
			Case "0"
				WriteStringN(FF, ";  [ ] Enable XP skin support", Format)
			Default
				WriteStringN(FF, ";  [x] Enable XP skin support", Format)
		EndSelect
		Select ReadPBPrefs("CompilerDefaults", "VistaAdmin")
			Case "0"
				WriteStringN(FF, ";  [ ] Request Administrator mode for Windows Vista", Format)
			Default
				WriteStringN(FF, ";  [x] Request Administrator mode for Windows Vista", Format)
		EndSelect
		Select ReadPBPrefs("CompilerDefaults", "VistaUser")
			Case "0"
				WriteStringN(FF, ";  [ ] Request User mode for Windows Vista (no virtualization)", Format)
			Default
				WriteStringN(FF, ";  [x] Request User mode for Windows Vista (no virtualization)", Format)
		EndSelect
	CompilerEndIf
	WriteStringN(FF, "; Library Subsystem:  " + ReadPBPrefs("CompilerDefaults", "SubSystem"), Format)
	Select ReadPBPrefs("CompilerDefaults", "TextEncoding")
		Case "1"
			WriteStringN(FF, "; File Format:        UTF-8", Format)
		Default
			WriteStringN(FF, "; File Format:        ASCII", Format)
	EndSelect
	CompilerIf #PB_Compiler_OS = #PB_OS_Windows
		Select ReadPBPrefs("CompilerDefaults", "ExeFormat")
			Case "1"
				WriteStringN(FF, "; Executable Format:  Console", Format)
			Case "2"
				WriteStringN(FF, "; Executable Format:  Shared DLL", Format)
			Default
				WriteStringN(FF, "; Executable Format:  Windows", Format)
		EndSelect
	CompilerElse
		Select ReadPBPrefs("CompilerDefaults", "ExeFormat")
			Case "1"
				WriteStringN(FF, "; Executable Format:  Console", Format)
			Case "2"
				WriteStringN(FF, "; Executable Format:  Shared .so", Format)
			Default
				WriteStringN(FF, "; Executable Format:  Linux", Format)
		EndSelect
	CompilerEndIf
	WriteStringN(FF, ";", Format)
	WriteStringN(FF, "; Created on:         " + FormatDate("%dd/%mm/%yyyy %hh:%ii", Date()), Format)
	WriteStringN(FF, "; App/Lib-Name:       " + gettitle$, Format)
	WriteStringN(FF, "; Author:             " + #AUTHOR_DEFAULT$, Format)
	WriteStringN(FF, "; Version:            " + getversion$, Format)
	WriteStringN(FF, "; Compiler:           " + GetPBCompilerVersion(), Format)
	WriteStringN(FF, "; ==============================================================", Format)
	WriteStringN(FF, "", Format)
	WriteStringN(FF, "EnableExplicit", Format)
	WriteStringN(FF, "", Format)
	CloseFile(FF)
EndIf 
;}
Zebuddi. :D
malleo, caput, bang. Ego, comprehendunt in tempore
Post Reply