text editor

You need some new stunning features ? Tell us here.
k3pto
User
User
Posts: 45
Joined: Sat Jan 17, 2015 5:24 pm

text editor

Post by k3pto »

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.
User avatar
flaviofornazier
New User
New User
Posts: 9
Joined: Mon Jan 06, 2014 8:28 pm
Location: Brazil

Re: text editor

Post by flaviofornazier »

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.62 x86/64 - WXP - W7/x86-64 - W8/x64 - W10/x64 - Ubuntu 16/x64 - OSX Yosemite 10.9
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8188
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: text editor

Post by netmaestro »

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.
BERESHEIT
User avatar
Keya
Addict
Addict
Posts: 1865
Joined: Thu Jun 04, 2015 7:10 am

Re: text editor

Post by Keya »

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: Select all

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: Select all

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: Select all

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
IdeasVacuum
Always Here
Always Here
Posts: 6380
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: text editor

Post by IdeasVacuum »

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.
Marc56us
Addict
Addict
Posts: 1098
Joined: Sat Feb 08, 2014 3:26 pm
Location: France

Re: text editor

Post by Marc56us »

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 use an online translator.)
User avatar
Tenaja
Addict
Addict
Posts: 1820
Joined: Tue Nov 09, 2010 10:15 pm

Re: text editor

Post by Tenaja »

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.
k3pto
User
User
Posts: 45
Joined: Sat Jan 17, 2015 5:24 pm

Re: text editor

Post by k3pto »

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.
collectordave
Addict
Addict
Posts: 1256
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: text editor

Post by collectordave »

Hi k3pto

I am a newbie as well but here is some help.
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.
collectordave
Addict
Addict
Posts: 1256
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: text editor

Post by collectordave »

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.
Post Reply