If you have the source code of simple text editor written in PureBasic, contact with me.
What I mean under words simple text editor ? Similiar to Angel Text Editor:
http://www.angelicsoftware.com/en/angel-writer.html
Or, may be, you can write in PB the same editor for me and sell the source code.
PB source code of text editor
Here's a tabbed notebook example I posted some time back:
viewtopic.php?t=9881&postdays=0&postorder=asc&start=6
And here it is updated for v4.
viewtopic.php?t=9881&postdays=0&postorder=asc&start=6
And here it is updated for v4.
Code: Select all
; Tabbed Notebook example by GedB.
; Updated to PB4 15/3/2006 (took a couple of minutes, don't know why everybody keeps complaining ;)
;- Standard Procedures
Procedure Die(Message.s)
MessageRequester("Fatal Error", Message)
End
EndProcedure
;- Window Constants
;
Enumeration
#Window_Main
EndEnumeration
;- MenuBar Constants
;
Enumeration
#MenuBar_2
EndEnumeration
Enumeration
#MENU_New
#MENU_Open
#MENU_Close
#MENU_Exit
#MENU_Nothing
#MENU_About
EndEnumeration
;- Gadget Constants
;
#Maximum_Number_Of_Tabs = 10
Enumeration
#TabbedPanel
#EditorGadget
#NextGadget = #EditorGadget + #Maximum_Number_Of_Tabs
EndEnumeration
;-Files
Enumeration
#TextFile
EndEnumeration
;-Structures
Structure NotebookTab
File_Path.s
EndStructure
;-Global Variables
Global Tabbed_Panel_Handle
Global Current_Tab
Global Last_Tab
Last_Tab = -1
GlobalCurrent_Tab = -1
Global Dim Tabs.NotebookTab(#Maximum_Number_Of_Tabs)
Procedure Open_Window_Main()
If OpenWindow(#Window_Main, 0, 0, 600, 431, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_WindowCentered , "Tabbed Notedbook") = 0
Die("Unable to Create Main Window")
EndIf
If CreateMenu(#MenuBar_2, WindowID(0)) = 0
Die("Unable to Create Menubar for Main Window")
EndIf
MenuTitle("File")
MenuItem(#MENU_New, "New")
MenuItem(#MENU_Open, "Open")
MenuItem(#MENU_Close, "Close")
MenuItem(#MENU_Exit, "Exit")
MenuTitle("Edit")
MenuItem(#MENU_Nothing, "Nothing here yet")
MenuTitle("Help")
MenuItem(#MENU_About, "About")
If CreateGadgetList(WindowID(0)) = 0
Die("Unable to Create GadgetList for Main Window")
EndIf
Tabbed_Panel_Handle = PanelGadget(#TabbedPanel, 0, 10, 600, 420)
CloseGadgetList()
DisableMenuItem(#MenuBar_2, #MENU_Nothing, 1)
EndProcedure
;-Procedures
Procedure Change_Tab(TabID.l)
If TabID < 0 Or TabID > Last_Tab
MessageRequester("Cannot Change Tab", Str(TabID) + " is not a valid tab")
Else
SetGadgetState(#TabbedPanel, TabID)
EndIf
EndProcedure
Procedure Add_Tab(Label.s)
If Last_Tab >= #Maximum_Number_Of_Tabs
MessageRequester("Cannot Add Tab", "You will have To close a tab before opening any more")
Else
Last_Tab = Last_Tab + 1
Current_Tab = Last_Tab
;Add our new tab to the array
Tabs(Current_Tab)\File_Path = ""
;Add the new tab to the panel gadget
If UseGadgetList(Tabbed_Panel_Handle) = 0
Die("Unable to Use GadgetList for new tab")
EndIf
AddGadgetItem(#TabbedPanel, -1, Label)
EditorGadget(#EditorGadget + Current_Tab, 8, 8, 580, 360)
Change_Tab(Current_Tab)
EndIf
EndProcedure
Procedure Create_New_File()
Add_Tab("<New>")
EndProcedure
Procedure Open_Existing_File()
File_Path.s = OpenFileRequester("Open Text File", "", "*.*", 0)
If OpenFile(#TextFile, File_Path) = 0
MessageRequester("Cannot Load File", File_Path + " is not a valid file.")
Else
Add_Tab(GetFilePart(File_Path))
Tabs(Current_Tab)\File_Path = File_Path
ClearGadgetItemList(#EditorGadget + Current_Tab)
While Eof(#TextFile) = 0
File_Line.s = ReadString(#TextFile)
AddGadgetItem(#EditorGadget+Current_Tab, -1, File_Line)
Wend
CloseFile(#TextFile)
EndIf
Change_Tab(Current_Tab)
EndProcedure
Procedure Remove_Tab(TabID)
If TabID < 0 Or TabID > Last_Tab
MessageRequester("Cannot Remove Tab", Str(TabID) + " is not a valid tab")
Else
If TabID < Last_Tab
For i = TabID To Last_Tab - 1
Tabs(i)\File_Path = Tabs(i + 1)\File_Path
SetGadgetItemText(#TabbedPanel, i, GetGadgetItemText(#TabbedPanel, i + 1, 0), 0)
SetGadgetText(#EditorGadget + i, GetGadgetText(#EditorGadget + i + 1))
Next
EndIf
RemoveGadgetItem(#TabbedPanel, Last_Tab)
Last_Tab = Last_Tab - 1
If Last_Tab < 0
Create_New_File()
ElseIf Current_Tab < Last_Tab
Change_Tab(Current_Tab)
Else
Change_Tab(Last_Tab)
EndIf
EndIf
EndProcedure
Procedure Close_Current_Tab()
Remove_Tab(Current_Tab)
EndProcedure
;-Event Loop
Procedure Event_Loop()
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
Select EventMenu()
;File Menu
Case #MENU_New
Create_New_File()
Case #MENU_Open
Open_Existing_File()
Case #MENU_Close
Close_Current_Tab()
Case #MENU_Exit
Event = #PB_Event_CloseWindow
;Edit Menu (nothing here yet)
;Help Menu
Case #MENU_About
MessageRequester("Feel the PuRe Power", "Tabbed Notebook example")
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #TabbedPanel
Current_Tab = GetGadgetState(#TabbedPanel)
Case #EditorGadget + Current_Tab
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndProcedure
;-Initialisation
Open_Window_Main()
Create_New_File()
Event_Loop()
of course! that's why we're sort of programmers instead of sort of users 
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )




