It is currently Fri Sep 22, 2017 9:46 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: text editor
PostPosted: Mon Sep 12, 2016 1:44 am 
Offline
User
User

Joined: Sat Jan 17, 2015 5:24 pm
Posts: 20
I am a newbie to PB and would like to know if anyone can point me to a simple text editor that I can use to help learn how to use PB and some of its gadgets.


Top
 Profile  
Reply with quote  
 Post subject: Re: text editor
PostPosted: Mon Sep 12, 2016 4:12 am 
Offline
New User
New User
User avatar

Joined: Mon Jan 06, 2014 8:28 pm
Posts: 6
Location: Brazil
Hi K3pto!

The Purebasic Editor itself is very intuitive, but there many
others that can help you. Please try do a search here with
the keywords "IDE, RAD, Editor", etc.

I'm a newbie too and I'm always doing searches about PB
over all the internet.

Best regards.

_________________
PB 5.50 - W7/x86 - W8/x64 - Ubuntu 16/x64 - OS X Yosemite 10.9


Top
 Profile  
Reply with quote  
 Post subject: Re: text editor
PostPosted: Mon Sep 12, 2016 4:13 am 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 7936
Location: Kelowna, BC, Canada
If you're a new user the best text editor for you would be the PureBasic IDE in my opinion. You can test your code from there and get debugger messages immediately.

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: text editor
PostPosted: Mon Sep 12, 2016 4:44 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 04, 2015 7:10 am
Posts: 1673
i think ive seen mention of some people using ones like Ultraedit where you can macro/program them but that sounds more complicated to me, and i think the PB IDE is pretty good

or you could make your own text editor!?

pbnotepad.pb ...
Code:
Global gsFilename.s
XIncludeFile("pbnotepad.pbf")
XIncludeFile("helpers.pbi")

OpenDlg1()

Define event.i
Repeat         ;main message loop
  event = WaitWindowEvent()
  Dlg1_Events (event)
Until event = #PB_Event_CloseWindow
End

pbnotepad.pbf ...
Code:
Enumeration FormWindow
  #Dlg1
EndEnumeration

Enumeration FormGadget
  #Editor1
EndEnumeration

Enumeration FormMenu
  #mnuNew
  #mnuOpen
  #mnuSave
  #mnuSaveAs
  #mnuExit
  #mnuAbout
EndEnumeration

Declare ResizeGadgetsDlg1()

Declare mnuAbout(Event)
Declare mnuOpen(Event)
Declare mnuSave(Event)
Declare mnuNew(Event)
Declare mnuSaveAs(Event)
Declare mnuExit(Event)

Procedure OpenDlg1(x = 0, y = 0, width = 568, height = 372)
  OpenWindow(#Dlg1, x, y, width, height, "PBNotepad", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered | #PB_Window_WindowCentered)
  CreateMenu(0, WindowID(#Dlg1))
  MenuTitle("File")
  MenuItem(#mnuNew, "New")
  MenuItem(#mnuOpen, "Open...")
  MenuItem(#mnuSave, "Save")
  MenuItem(#mnuSaveAs, "Save As...")
  MenuBar()
  MenuItem(#mnuExit, "Exit")
  MenuTitle("Help")
  MenuItem(#mnuAbout, "About")
  EditorGadget(#Editor1, 0, 0, 568, 350, #PB_Editor_WordWrap)
EndProcedure

Procedure ResizeGadgetsDlg1()
  Protected FormWindowWidth, FormWindowHeight
  FormWindowWidth = WindowWidth(#Dlg1)
  FormWindowHeight = WindowHeight(#Dlg1)
  ResizeGadget(#Editor1, 0, 0, FormWindowWidth - 0, FormWindowHeight - MenuHeight() - 0)
EndProcedure

Procedure Dlg1_Events(event)
  Select event
    Case #PB_Event_SizeWindow
      ResizeGadgetsDlg1()
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
        Case #mnuNew
          mnuNew(EventMenu())
        Case #mnuOpen
          mnuOpen(EventMenu())
        Case #mnuSave
          mnuSave(EventMenu())
        Case #mnuSaveAs
          mnuSaveAs(EventMenu())
        Case #mnuExit
          mnuExit(EventMenu())
        Case #mnuAbout
          mnuAbout(EventMenu())
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure

helpers.pbi
Code:
Procedure SetMainTitle()
  SetWindowTitle(#Dlg1, "PBNotepad - " + GetFilePart(gsFilename))
EndProcedure


Procedure mnuNew(eventid)
  gsFilename = ""
  SetGadgetText(#Editor1, "")
  SetMainTitle()
EndProcedure


Procedure mnuOpen(eventid)
  Protected sOpenfile.s = OpenFileRequester("Select file to open...", "", "", 0)
  If sOpenfile <> ""
    Protected hFile = ReadFile(#PB_Any, sOpenfile)
    If hFile = 0
      MessageRequester("Error", "Couldn't open file")
    Else
      Protected sBuf.s
      sBuf = ReadString(hFile, #PB_Ascii | #PB_File_IgnoreEOL, -1)
      CloseFile(hFile)
      SetGadgetText(#Editor1, sBuf)
      gsFilename = sOpenfile
      SetMainTitle()
    EndIf
  EndIf
EndProcedure


Procedure SaveToFile(sFile.s)
    Protected hFile = CreateFile(#PB_Any, sFile)
    If hFile = 0
      MessageRequester("Error", "Couldn't create file")
    Else
      WriteString(hFile, GetGadgetText(#Editor1), #PB_Ascii)
      CloseFile(hFile)
      gsFilename = sFile
    EndIf
    SetMainTitle()
EndProcedure


Procedure mnuSaveAs(eventid)
  Protected sFile.s = SaveFileRequester("Save file as...", "", "", 0)
  If sFile <> ""
    SaveToFile(sFile)
  EndIf
EndProcedure


Procedure mnuSave(eventid)
  If gsFilename <> ""
    SaveToFile(gsFileName)
  Else
    mnuSaveAs(eventid)
  EndIf
EndProcedure


Procedure mnuExit(eventid)
  End
EndProcedure


Procedure mnuAbout(eventid)
  MessageRequester("PBNotepad", "Simple start to a basic text editor")
EndProcedure

_________________
Thankyou to all the coders who generously helped & encouraged me in the nearly 2yrs when i was welcome here,
it was a tremendous privilege. I learned a lot. I wish you and your families all the best and success for the future.


Top
 Profile  
Reply with quote  
 Post subject: Re: text editor
PostPosted: Mon Sep 12, 2016 5:26 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5664
Location: Wales, UK
I think a few people use either UltraEdit or NotePad++ since they are feature rich and it's much easier to use just the one editor if you have to use more than one programming language.

Personally I use UltraEdit - Column mode editing and macros are very handy tools. Multiple tabs are spread over multiple rows on bigger projects so you can still see what you have loaded and 1-click to any source. The PB IDE and Visual Studio both auto-detect changes to source files so it all works rather well.

Edit: PB's graphical Window Form Designer is good, if a bit restrictive. I use it to define the intial layout of my forms and beyond that manually edit them, which is very easy.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: text editor
PostPosted: Mon Sep 12, 2016 7:07 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 288
Location: France
k3pto wrote:
I am a newbie to PB and would like to know if anyone can point me to a simple text editor that I can use to help learn how to use PB and some of its gadgets.

If you start in PB, the best IDE is the internal editor. The main interesting thing is the syntax helper in status bar. Alway look at bottom screen when typing.
(The only downside of this function is that it does not understand embedded commands :| )

PS. Alway start new code with EnableExplicit :idea:
:arrow: You will gain a lot of time because of typos :!:

Have a good time with PB 8)

_________________
(English is not my native language, I used an online translator)
mdacme.com


Top
 Profile  
Reply with quote  
 Post subject: Re: text editor
PostPosted: Mon Sep 12, 2016 4:15 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 1486
k3pto wrote:
I am a newbie to PB and would like to know if anyone can point me to a simple text editor that I can use to help learn how to use PB and some of its gadgets.

If you are looking for a sample die to edit yourself, search for goscintilla.


Top
 Profile  
Reply with quote  
 Post subject: Re: text editor
PostPosted: Tue Sep 13, 2016 4:59 pm 
Offline
User
User

Joined: Sat Jan 17, 2015 5:24 pm
Posts: 20
Thank you all for the quick replies. I think I need to be a little clearer in future posts...

The example from Keya is just what I was looking for - an example of PB code that creates a simple editor.
However, after reviewing and running the code, I do have a question: where do the menu bar, its contents and Dlg1 come from? I did not see them in the PB list of objects. I did see a menu gadget but I could not figure how to add items to it.


Top
 Profile  
Reply with quote  
 Post subject: Re: text editor
PostPosted: Sun Feb 05, 2017 8:41 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 684
Location: Portugal
Hi k3pto

I am a newbie as well but here is some help.

Quote:
However, after reviewing and running the code, I do have a question: where do the menu bar, its contents and Dlg1 come from? I did not see them in the PB list of objects. I did see a menu gadget but I could not figure how to add items to it.


Look for

OpenDlg1() in the file pbnotepad.pb

This is telling the programme to run the procedure OpenDlg1()

then look for

Procedure OpenDlg1(x = 0, y = 0, width = 568, height = 372) in the file pbnotepad.pbf

That is the procedure that creates the Dlg and is where the menu is created.

Hope this helps a little

Regards

cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: text editor
PostPosted: Sun Feb 05, 2017 5:45 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 684
Location: Portugal
Print and print preview added to the notepad application written by keya no font selection.

All available here https://github.com/collectordave/PureBasic-NotePad

Regards

cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Baidu [Spider] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye